| Issue |
60973
|
| Summary |
[clang-format] incorrect result with preprocessor inside initializer list
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Sam0523
|
Given the input C++ file:
```C++
struct A {
A();
std::map<int, int> m;
};
A::A() : m({
{1, 1},
{2, 2},
#if defined(AAA)
{3, 3},
#endif
{4, 4},
}) {
}
```
After formatting by command `clang-format --style=llvm`:
```C++
struct A {
A();
std::map<int, int> m;
};
A::A()
: m({
{1, 1}, {2, 2},
#if defined(AAA)
{3, 3},
#endif
{4, 4},
}) {
}
```
Expected result:
```C++
struct A {
A();
std::map<int, int> m;
};
A::A()
: m({
{1, 1},
{2, 2},
#if defined(AAA)
{3, 3},
#endif
{4, 4},
}) {
}
```
Also I have noticed that this only seems to happen with `#if`, but not `#ifdef`:
```C++
A::A()
: m({
{1, 1},
{2, 2},
#ifdef AAA
{3, 3},
#endif
{4, 4},
}) {
}
```
This gives the correct result as expected.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs