<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60146>60146</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Incorrect clang-format pointer alignment when variables are declared in conditionals
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          JohnC32
      </td>
    </tr>
</table>

<pre>
    Given:

```c++
void foo1(const T1* p1) {
    if (T2* v; check(&v, p1)) {
        goo(v);
 }
}
```

and `_clang-format`:

```yaml
---
BasedOnStyle: Google
IndentWidth: 4
# Google style default is PointerAlignment: Left,
PointerAlignment: Left
...
```

clang-format 15 yields the following. Notice the pointer alignment is no longer left, despite
asking for it to be left.

```c++
void foo1(const T1* p1) {
    if (T2 * v; check(&v, p1)) {
        goo(v);
 }
}
```

In this case, we scoped the variable declaration in the if conditional. If we move it out of the
conditional, pointer alignment is as expected:

```c++
void foo2(const T1* p1) {
    T2* v;
 if (check(&v, p1)) {
        goo(v);
    }
}
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VF1vmzAU_TXm5SoIDCTkgYekVapM0zZplfY4GfsCXh3fCDtk-feTgbSduq6api1CAd1zjn3uhy2c061FrFixZcVtJE6-o756R529yXhUk7pUd3pAy7INS25Zcv1fJtMjGd-GZ4wOpBU0RCnjpSTrPNynjG_gmDK-BraaaQAAugHGy3se4IFlW5AdygfGS8aXA-M3k-aFLPxaIsbLIcDZFWKr29nY48fV4XPbwipgy-SrNMK2i4b6g_CB8kpyF3EwU2ixWEwfW-FQfbSf_cUgyzZwR9QanLC9VWj9F618F6B8Xo1nMwtcUIHCRpyMB-3gE2nrsd8Y3doDWh9k77HxjN9M4lcJIxrH8W-SfZ4kpAVcNBrlwHcIDRlDZ23bGD6Q1xLH6HHaDMR1t2DREhiyLfZgJmOg0B21n3MW7kHbFhrqQXvwBDWOxPifTAv833HZW_CddiCFw7DJGcFJOqIayzWIXot6bKg0ohdekwVtR0w3IMkqHWLCxLBvgvhAA4Yy0ckDNYE4d-qJOubyqz4IB_j9iNKj-qOzyN-u7tMpnGNTuf-uxABvVzlSVabW2VpEWKXLVZ5ma14UUVflWb7KE1lLuSpVWiRYqhzrNEmyUkjVYKQrnvAsSdN1mudJUcS8QL7ishB5rsqSK5YneBDaxMYMh5j6NtLOnbBaJmm-jIyo0bjx0uPc4hlGkHEe7sC-CppFfWodyxOjnXdPq3jtDVZ7K6nvUXr46ZC9bNy5Q_s4KA5Ef50WVGFUnjXeRafeVJ33Rxf6y3eM71rtu1MdSzowvgsW5tfi2NM3lJ7x3WjcMb4bE_sRAAD__7QCqFs">