<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60845>60845</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tidy -fix does not follow symlinks before rewriting
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
randombit
</td>
</tr>
</table>
<pre>
If `clang-tidy` fixes a file, and the path that `clang-tidy` used to locate the file was actually a symlink, instead of updating the pointed-to-file, the symlink is removed and a new file placed there.
Simple example
```
inc/foo.h -> ../src/foo.h
src/foo.h
src/foo.cpp
```
if `clang-tidy` wants to rewrite `foo.h`, and it found `foo.h` via `-Iinc`, it will replace `inc/foo.h` instead of following the symlink and modifying `src/foo.h`
```
$ clang-tidy -version
LLVM (http://llvm.org/):
LLVM version 15.0.7
Optimized build.
Default target: x86_64-pc-linux-gnu
Host CPU: skylake
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U02PpDYQ_TXmUgKB6abhwGGyk1ZW2iiRouQaGVxAZYyNcNEf-fWRaZjpJKOVEJarXn2890B5T71FrMXxB3F8jdTCg5vrWVntxoY4apy-1187EEXaGmX7mEnfRZFCRzf0oKAjg0J-AWU18IAwKR6AB8X_L1k8amAHxrWKcUWHargqD6rlRRlzBwX-Phqyb6EpWc-oNLgOlkkrJts_hjiyjDpmF-_zQ3irBPIw4-guqNe1FFi8PkZNRrW4LjpjItJXkb483r_ROBkEvKlwPmdEkW7PeiXbCnnunEsGiEX-IySJkGc_v0cfsO8E2mn6tPPW_xOtr8qyD8rNeJ2JMSAerYt0154YOrdY_ZyDC6lwj7-GrR9YYriSMTDjqkVIP1EKRU-id84Yd91V3-UN40anqbuHjCjSZ7L_ZvNfivIAH9QgvuDsydlH8tu3P34GIcuBeRL5i5BnIc_GXMbEzf16q0J4xQKs6K0esmOSJqc99cvENNLfqKFZyOjNZ3jFTi2GgdXcI4v8BW5l8WdxiKc2NmSXW9zbZe_xk_MMX379PcD8292oN_yUUaTrXFd5pSKss-JUFCdZplk01JlUUpcqV7orCynLquzaTLZdXlVKV3kbUS1TmacyO0kpi0OWyJOuFDbNqemyotGFOKQ4KjLJrkFE3i9YF2l5OEZGNWj8_t_OdQDFzdJ7cUgNefYfZUxssH7WvaMbaIcerOPN5N1dDw12bsbtWyPbR8ts6mCKf3elJx6WJmnduFm0HfE0u7-wZSHP665eyPO67j8BAAD__8b_XrY">