<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55161>55161</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
strange alignment and indentation with clang-format's AlignConsecutiveAssignments: true
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zmodem
</td>
</tr>
</table>
<pre>
Consider:
```
$ cat /tmp/a.cc
#if A
bool thisisalongvariablename = true;
#else
bool thisisalongvariablename = false;
#endif
#if B
bool shortervarname = true;
#else
bool shortervarname = false;
#endif
void foo() {
#if C
#else
if (bar) {
baz();
}
#endif
}
$ build.release/bin/clang-format -style="{AlignConsecutiveAssignments: true}" /tmp/a.cc
#if A
bool thisisalongvariablename = true;
#else
bool thisisalongvariablename = false;
#endif
#if B
bool shortervarname = true;
#else
bool shortervarname = false;
#endif
void foo() {
#if C
#else
if (bar) {
baz();
}
#endif
}
```
Note that the second assignment to shortervarname gets aligned, but not the first one.
And the indentation for baz() is wrong.
The issues seem to be connected.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlU8uO2yAU_Rq8QbEIfiReeJGHZtlVfwDMtUOFIQKc0czX99pOPMkoUqNuuiiysOE-zjHnIJ36qA_OBq3Ak2xH2JGw21yy6zMveU4bESnhb7E_4yzSprmFMt3Sa5l0ztB40kEHYZztLsJrIQ1Y0QMl2ZFGPwDJ9kspmAAvlrZizL2vtUq3D6QnKvu7fuHkfASPvV5l8KTiz8AXpxVtnSN8S3hFyWZ_T-jwBItSDGC6FP6hguKQ4nNutGBSTDg-hV-2F5nkoI1KPRgQCMbfpLY4N0bYbtU636OKqxA_DP7RkXCOyDujOzv6AJoh6gvsQsCNHmwM6Ir5wDZj7qP89H_Qfxn_wgjL-CtHfLvB0_zDRcBDRg_EE1AU3FlFxaI3je77AXQQAxWjQ0ARfkB7RWrdXN9qHyJ1FtK5-w6bjfvaKmwmonYWD8N_0ac60HeP4l4Lfo7JIQwQkAv0I7wEiqQsNBFUmqg6U1VWiSTqaKAO0aONYeYzERYIeQ_3ruOJ3pud8E2gLzg8GbypTzGexx10OD4d9hpk2rgeF8Zcbq_V2btfSBCXM3n8KIp1uU5ONds2QlZlJiDfsIbxLK9EpbKigmpdlG2ZGCFR_JoUe7xQj0Q5KY6JrjnjnOV8yyqWsW26LnmxaUWTVzIryrwlOYNeaJOOVFLnu8TXEys5dAGDRocYvoKzuAATIvYXQ0SB68_eKeiTiX89kf8NrH_Q3g">