<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62892>62892</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] Regression in current main branch (llvm 17)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Sedeniono
</td>
</tr>
</table>
<pre>
Consider the following minimal example:
```C++
struct foo {
void test() {
#if 1
#else
#endif
}
#if 1
private:
#endif
};
```
The new lines after the `private:` are important, as are the initial `#if 1..else..endif`.
The `.clang-format` file contains a single line:
```
IndentPPDirectives: BeforeHash
```
Using the current llvm main branch to format the whole file, this triggers the message
```
The new replacement overlaps with an existing replacement.
New replacement: x86_amd64_replbug-reduced.hpp: 64:+3:"
"
Existing replacement: x86_amd64_replbug-reduced.hpp: 64:+3:"
"
```
while in clang-format 16 this does not happen.
I could bisect it to a4c87f8ccaccc76fd7d1c6c2e639ca84b9ec7794, which apparently is related to #61498. Differential revision: https://reviews.llvm.org/D150057
Maybe @owenca does have an idea?
I noticed the above regression while looking at the example from #57117, and managed to reduce it to the above
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE2P5CYQ_TX4UhoL4-9DH3am08oeEq2SzXlFQ9muBIMFuHvm30fYrZnuZJRLJMs2UB_vvapChkCjRTyw-pnVx0yucXL-8DtqtOSsy85Ovx1enA2k0UOcEAZnjLuSHWEmS7M0gK9yXgyy8gvjR8a_sIbvzwsTz-nZdkP0q4owOAesve0x3l8caYgYIhMdE_3dmShpgOJ9gSbgx8JqGt5jsPb4ic_i6SLjHaz792OI9sjK53-A35ffJwSLVzBkMYAc4k0F1vC7-A0H6RFoXpyP0kYmXkCGbS8Zk6VI0iSnG8I8T3TyfAfR8Bzu0X3fE-TKSDs-Dc7PMqYcAxkE5WyUZANICGRHgxu2f4u_L79ajTZ--3YkjyrSBQMrv8AzDs7j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