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

    <tr>
        <th>Summary</th>
        <td>
            Incorrect handling of preprocessor #token stringification and worse in clang-format 15
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    Given:

```c++
#define FOO(typeName, realClass) \
    { #typeName, std::unique_ptr<FooType>(new FooBasicType<realClass>(#typeName)) }

#define BAR(typeName, realClass) \
    { typeName, std::unique_ptr<FooType>(new FooBasicType<realClass>(typeName)) }
```

and `_clang-format`:

```yaml
---
BasedOnStyle: Google
ColumnLimit: 100
IndentWidth: 4
...
```

clang-format 13 and 14 yields:

```c++
#define FOO(typeName, realClass) \
    { #typeName, std::unique_ptr < FooType>(new FooBasicType <realClass>(#typeName)) }

#define BAR(typeName, realClass) \
    { typeName, std::unique_ptr<FooType>(new FooBasicType<realClass>(typeName)) }
```

Notice with clang-format 13 and 14 that spaces were added near the "<" when the C preprocessor token
stringification (#) was used. These extra spaces should not be present. If we remove the '#'
character, the result is correct as shown in the BAR macro.

clang-format 15 yields a worse result when the stringification #token is present (in my opinion):

```yaml
#define FOO(typeName, realClass)                                                       \
    {                                                                                  \
#typeName, std::unique_ptr < FooType>(new FooBasicType <realClass>(#typeName)) \
    }

#define BAR(typeName, realClass) \
    { typeName, std::unique_ptr<FooType>(new FooBasicType<realClass>(typeName)) }
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlVNtu2zAM_Rr7hYhhy3YSP_ghcdeiw9AC24A9FrLNxNpkKZPkZvn70XaSNi3SXVBsGCYIvpAUeUgeqtT1Lr8S96i8eOGFF154eE7DcVceW_Z7lLK4xpVQCJe3tx6bu90Gb3iLHivAIJeF5NZ6LAMvLcYTQMubLYFOPja2ru4DxotOia8d3m2c8eLiUuuPZOTFb8i3wi2QYMmtqEZp8RBisDjxmQ1hZxcnSRzhLhfvfwnuq2M9C_RQ58e4uaqBRHeV5Go9WWnTctebnGnRjrdyFE0mk_GDkGB9qz64nSQwC7jSek1fg67QsmvVO9EK16uicB_7WtWo3CdRu6aXJ6M0CIIXkD5GCFEMPfIogZ1AWdu_TimgPsCLjYL_iFU32okKYStcA2f65hr6tRteoYUtGgRe11iDQm5IR9VijEDQE7YNqkFUwMbgxmg6YjVZ6S90lwzxrDNCrcVKVNwJrWCsbY9zyy10RNAAPjZoEfCbM_wQ1za6kxRTOyixd26JlQFcrwgR1bfV97jHMhvczfZMbLjhlUPTF7fX08FOOhAWKm0MVg744HyrQIzQqX3Q8sro4Dyl0z2XgcNWG3t0e8z_eZbxUIM-8B58nzmFbHegN0KRUd-uH87yTw_G761n5Hz1dYzw5wb1NKd_fGp9zKPpNI6mScpCv87jOosz7jvhJObX6sDqhmZXEgVBr05H8cjEpxTth30kM7HyCd39zsi8cW4z3N7skvaaLoyuDCrd0o-U94fXhEJ9JgT0K6ztkKp3mc5m8dxv8nCGEcMsWVXTpA5ZlmbpPA5nUZxUOA9x6kteorS5ly699MIXOQsZC7MoiZJwnoRBlrCqpGzLeVlzPp96SYgtFzLoAwfarH2TDxjKbm1JKYV19kFJpRZrhXjwzzvXaJO_1Y0qYuYPcPMB63fLiqCK">