Vladimir Vuksanovic 34c85ed2bc
[clang-reorder-fields] Use expanded location for macros (#142147)
Fixes macros being replaced instead of their expansion.

Closes #52632
2025-06-15 18:07:51 -04:00

25 lines
725 B
C++

// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,y,x %s -- | FileCheck %s
namespace bar {
#define INT_DECL(NAME) int NAME // CHECK: {{^#define INT_DECL\(NAME\) int NAME}}
#define MACRO_DECL int x; // CHECK-NEXT: {{^#define MACRO_DECL int x;}}
struct Foo {
MACRO_DECL // CHECK: {{^ INT_DECL\(z\);}}
int y; // CHECK-NEXT: {{^ int y;}}
INT_DECL(z); // CHECK-NEXT: {{^ MACRO_DECL}}
};
#define FOO 0 // CHECK: {{^#define FOO 0}}
#define BAR 1 // CHECK-NEXT: {{^#define BAR 1}}
#define BAZ 2 // CHECK-NEXT: {{^#define BAZ 2}}
struct Foo foo = {
FOO, // CHECK: {{^ BAZ,}}
BAR, // CHECK-NEXT: {{^ BAR,}}
BAZ, // CHECK-NEXT: {{^ FOO,}}
};
} // end namespace bar