Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -0,0 +1,14 @@
// RUN: clang-reorder-fields -record-name Foo -fields-order z,y,x %s -- | FileCheck %s
// The order of fields should not change.
class Foo {
public:
int x; // CHECK: {{^ int x;}}
int y; // CHECK-NEXT: {{^ int y;}}
int z; // CHECK-NEXT: {{^ int z;}}
};
int main() {
Foo foo = { 0, 1 }; // CHECK: {{^ Foo foo = { 0, 1 };}}
return 0;
}

View File

@ -0,0 +1,18 @@
// RUN: clang-reorder-fields -record-name ::Foo -fields-order y,x %s -- | FileCheck %s
struct Foo {
int x; // CHECK: {{^ double y;}}
double y; // CHECK-NEXT: {{^ int x;}}
};
namespace bar {
struct Foo {
int x; // CHECK: {{^ int x;}}
double y; // CHECK-NEXT: {{^ double y;}}
};
} // end namespace bar
int main() {
bar::Foo foo = { 1, 1.7 }; // CHECK: {{^ bar::Foo foo = { 1, 1.7 };}}
return 0;
}

View File

@ -0,0 +1,16 @@
// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,w,y,x %s -- | FileCheck %s
namespace bar {
struct Foo {
const int* x; // CHECK: {{^ double z;}}
int y; // CHECK-NEXT: {{^ int w;}}
double z; // CHECK-NEXT: {{^ int y;}}
int w; // CHECK-NEXT: {{^ const int\* x}}
};
} // end namespace bar
int main() {
const int x = 13;
bar::Foo foo = { &x, 0, 1.29, 17 }; // CHECK: {{^ bar::Foo foo = { 1.29, 17, 0, &x };}}
return 0;
}

View File

@ -0,0 +1,33 @@
// RUN: clang-reorder-fields -record-name bar::Derived -fields-order z,y %s -- | FileCheck %s
namespace bar {
class Base {
public:
Base(int nx, int np) : x(nx), p(np) {}
int x;
int p;
};
class Derived : public Base {
public:
Derived(long ny);
Derived(char nz);
private:
long y;
char z;
};
Derived::Derived(long ny) :
Base(ny, 0),
y(ny), // CHECK: {{^ z\(static_cast<char>\(ny\)\),}}
z(static_cast<char>(ny)) // CHECK-NEXT: {{^ y\(ny\)}}
{}
Derived::Derived(char nz) :
Base(1, 2),
y(nz), // CHECK: {{^ z\(x\),}}
z(x) // CHECK-NEXT: {{^ y\(nz\)}}
{}
} // namespace bar

View File

@ -0,0 +1,16 @@
// RUN: clang-reorder-fields -record-name Foo -fields-order z,y,x %s -- | FileCheck %s
// The order of fields should not change.
class Foo {
public:
int x; // CHECK: {{^ int x;}}
private:
int y; // CHECK: {{^ int y;}}
int z; // CHECK-NEXT: {{^ int z;}}
};
int main() {
Foo foo;
return 0;
}

View File

@ -0,0 +1,24 @@
// RUN: clang-reorder-fields -record-name Foo -fields-order e,x,pi,s2,s1 %s -- -std=c++11 | FileCheck %s
class Foo {
public:
Foo();
private:
int x; // CHECK: {{^ double e = 2.71;}}
const char *s1; // CHECK-NEXT: {{^ int x;}}
const char *s2; // CHECK-NEXT: {{^ double pi = 3.14;}}
double pi = 3.14; // CHECK-NEXT: {{^ const char \*s2;}}
double e = 2.71; // CHECK-NEXT: {{^ const char \*s1;}}
};
Foo::Foo():
x(12), // CHECK: {{^ x\(12\)}},
s1("abc"), // CHECK-NEXT: {{^ s2\("def"\)}},
s2("def") // CHECK-NEXT: {{^ s1\("abc"\)}}
{}
int main() {
Foo foo;
return 0;
}

View File

@ -0,0 +1,24 @@
// RUN: clang-reorder-fields -record-name Foo -fields-order s1,x,z,s2 %s -- | FileCheck %s
class Foo {
public:
Foo();
private:
int x; // CHECK: {{^ const char \*s1;}}
const char *s1; // CHECK-NEXT: {{^ int x;}}
const char *s2; // CHECK-NEXT: {{^ double z;}}
double z; // CHECK-NEXT: {{^ const char \*s2;}}
};
Foo::Foo():
x(12), // CHECK: {{^ s1\("abc"\),}}
s1("abc"), // CHECK-NEXT: {{^ x\(12\),}}
s2("def"), // CHECK-NEXT: {{^ z\(3.14\),}}
z(3.14) // CHECK-NEXT: {{^ s2\("def"\)}}
{}
int main() {
Foo foo;
return 0;
}

View File

@ -0,0 +1,54 @@
// RUN: clang-reorder-fields -record-name bar::Foo -fields-order y,z,c,x %s -- 2>&1 | FileCheck --check-prefix=CHECK-MESSAGES %s
// FIXME: clang-reorder-fields should provide -verify mode to make writing these checks
// easier and more accurate, for now we follow clang-tidy's approach.
namespace bar {
struct Dummy {
Dummy(int x, char c) : x(x), c(c) {}
int x;
char c;
};
class Foo {
public:
Foo(int x, double y, char cin);
Foo(int nx);
Foo();
int x;
double y;
char c;
Dummy z;
};
static char bar(char c) {
return c + 1;
}
Foo::Foo() : x(), y(), c(), z(0, 'a') {}
Foo::Foo(int x, double y, char cin) :
x(x),
y(y),
c(cin),
z(this->x, bar(c))
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: reordering field x after z makes x uninitialized when used in init expression
// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: reordering field c after z makes c uninitialized when used in init expression
{}
Foo::Foo(int nx) :
x(nx),
y(x),
c(0),
z(bar(bar(x)), c)
// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: reordering field x after y makes x uninitialized when used in init expression
// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: reordering field x after z makes x uninitialized when used in init expression
// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: reordering field c after z makes c uninitialized when used in init expression
{}
} // namespace bar
int main() {
bar::Foo F(5, 12.8, 'c');
return 0;
}

View File

@ -0,0 +1,36 @@
// RUN: clang-reorder-fields -record-name bar::Derived -fields-order z,y %s -- 2>&1 | FileCheck --check-prefix=CHECK-MESSAGES %s
// FIXME: clang-reorder-fields should provide -verify mode to make writing these checks
// easier and more accurate, for now we follow clang-tidy's approach.
namespace bar {
struct Base {
int x;
int p;
};
class Derived : public Base {
public:
Derived(long ny);
Derived(char nz);
private:
long y;
char z;
};
Derived::Derived(long ny) :
Base(),
y(ny),
z(static_cast<char>(y))
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: reordering field y after z makes y uninitialized when used in init expression
{}
Derived::Derived(char nz) :
Base(),
y(nz),
// Check that base class fields are correctly ignored in reordering checks
// x has field index 1 and so would improperly warn if this wasn't the case since the command for this file swaps field indexes 1 and 2
z(x)
// CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: reordering field x after z makes x uninitialized when used in init expression
{}
} // namespace bar

View File

@ -0,0 +1,14 @@
// RUN: clang-reorder-fields -record-name Foo -fields-order z,w,y,x %s -- | FileCheck %s
struct Foo {
const int* x; // CHECK: {{^ double z;}}
int y; // CHECK-NEXT: {{^ int w;}}
double z; // CHECK-NEXT: {{^ int y;}}
int w; // CHECK-NEXT: {{^ const int\* x}}
};
int main() {
const int x = 13;
struct Foo foo = { &x, 0, 1.29, 17 }; // CHECK: {{^ struct Foo foo = { 1.29, 17, 0, &x };}}
return 0;
}