-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Copy link
Labels
Milestone
Description
Running clang-format 19.1.4 twice produces different results when we have #define statements within an initializer. Running with clang-format 18.1.1 shows no difference on repeated invocations.
Given idempotent_define.cpp
namespace Foo {
void foo() {
#define GEN_ID(_x) \
char const *_x { \
#_x \
}
GEN_ID(one);
GEN_ID(two);
}
}using _clang-format:
---
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 100
...clang-format 19.1.4 yields the following differences on successive runs. Notice that define flips between being on a single line and multiple lines.
/path/to/llvm-19.1.4/bin/clang-format -style=file idempotent_define.cpp >out.19.1.4.a.cpp 2>&1
/path/to/llvm-19.1.4/bin/clang-format -style=file out.19.1.4.a.cpp >out.19.1.4.b.cpp 2>&1
/path/to/llvm-19.1.4/bin/clang-format -style=file out.19.1.4.b.cpp >out.19.1.4.c.cpp 2>&1
diff -u out.19.1.4.a.cpp out.19.1.4.b.cpp
--- out.19.1.4.a.cpp 2024-12-02 13:24:50.702497070 -0500
+++ out.19.1.4.b.cpp 2024-12-02 13:24:50.714497177 -0500
@@ -1,6 +1,7 @@
namespace Foo {
void foo() {
-#define GEN_ID(_x) char const *_x{#_x}
+#define GEN_ID(_x) \
+ char const *_x { #_x }
GEN_ID(one);
GEN_ID(two);
}
diff -u out.19.1.4.b.cpp out.19.1.4.c.cpp
--- out.19.1.4.b.cpp 2024-12-02 13:24:50.714497177 -0500
+++ out.19.1.4.c.cpp 2024-12-02 13:24:50.733497347 -0500
@@ -1,7 +1,6 @@
namespace Foo {
void foo() {
-#define GEN_ID(_x) \
- char const *_x { #_x }
+#define GEN_ID(_x) char const *_x{#_x}
GEN_ID(one);
GEN_ID(two);
}
diff -u out.19.1.4.a.cpp out.19.1.4.c.cppMetadata
Metadata
Assignees
Labels
Type
Projects
Status
Done