
Add checks to prevent rewriting when doing so might result in incorrect code. The following cases are checked: - There are multiple field declarations in one statement like `int a, b` - Multiple fields are created from a single macro expansion - Preprocessor directives are present in the struct
17 lines
418 B
C++
17 lines
418 B
C++
// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,y,x %s -- | FileCheck %s
|
|
|
|
namespace bar {
|
|
|
|
#define ADD_Z
|
|
|
|
// The order of fields should not change.
|
|
struct Foo {
|
|
int x; // CHECK: {{^ int x;}}
|
|
int y; // CHECK-NEXT: {{^ int y;}}
|
|
#ifdef ADD_Z // CHECK-NEXT: {{^#ifdef ADD_Z}}
|
|
int z; // CHECK-NEXT: {{^ int z;}}
|
|
#endif // CHECK-NEXT: {{^#endif}}
|
|
};
|
|
|
|
} // end namespace bar
|