<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60973>60973</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] incorrect result with preprocessor inside initializer list
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Sam0523
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUlc-OmzAQxp_GXEaJYBwCHDiQZFP13L6AgSG4AoPsIdv06SuTaJNutto_WqlqFMnIwzd4vp_tUc7pgyHKRbwR8S5QE7eDzb-pPoxRBuVQn_Iv-kgGuCXQZpwYtgI3AjfQ6I6ELES4E2Eh1uH5f4meZx3bqWIoQCSXGQCAQmAqMBPyMneNOK59Rln0ahRyqw0L3IIf5AP0V0GyeyYuzrJLZhCygN4_P31WJJvI54q8FrfXT_qfSDbog3gbFCh1AzU12lAtMC189uxOKL1QPhOSqXVz9-rKv7p6eQG7ednJTYF_2nops2Gy0Ay2V8zaHKA8QTX0vTI1iHVYdcocFucwLBaOT57QruuOvU_xflZ_I_VJnK4m3AO72nbL7eOo3onrFWRvBfbwc6SKqQZLbur4v0RwB-GF8EeZvIvIJ_AoOjfAV2jVkcAMrCuqgVvFwK12MJjuBI6od8ADtGocycCj5tYfrrmgedxCObGXP03X1Lx-wN5u_If9rqkBb_Q_dvm7N_Ogj-TmtlEN1lLFlzMAygFdjsUyqHNZZzJTAeXROklQppimQZuHq0iFWZQ2VSKzWGJGVRKVWZnE4ZqkpEDnGKIMEVdRJCNMl02cyKxOsZSrOKEkFauQeqW7pb_-loM9BNq5ifJ1mCUy6FRJnZvbHqKhR5iDAtF3QZt7zaKcDk6swk47dtcsrLmb--XtbSviHWjzrNB554yWRjtU5NxgQRuna99HNWvV6V9kwWcPJtvlLfPo_BbBvcD9QXM7lctq6AXu5wv8PCxGO_ygigXu5xU7gfu5ot8BAAD___iH7ZE">