llvm-project/clang-tools-extra/test/clang-reorder-fields/MacroExpandsToMultipleFields.cpp
Vladimir Vuksanovic a17b5bce8c
[clang-reorder-fields] Prevent rewriting unsupported cases (#142149)
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
2025-06-22 19:00:11 -07:00

14 lines
369 B
C++

// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,y,x %s -- | FileCheck %s
namespace bar {
#define FIELDS_DECL int x; int y; // CHECK: {{^#define FIELDS_DECL int x; int y;}}
// The order of fields should not change.
struct Foo {
FIELDS_DECL // CHECK: {{^ FIELDS_DECL}}
int z; // CHECK-NEXT: {{^ int z;}}
};
} // end namespace bar