<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61416>61416</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] add_new_check.py creates a faulty FixItHint
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RedPenguin100
</td>
</tr>
</table>
<pre>
When the `add_new_check.py` script is invoked to create a new vanilla custom clang-tidy check, the following code is emitted inside the check override function:
```cpp
diag(MatchedDecl->getLocation(), "function %0 is insufficiently awesome")
<< MatchedDecl;
diag(MatchedDecl->getLocation(), "insert 'awesome'", DiagnosticIDs::Note)
<< FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
```
Running clang tidy with `--fix` won't fix the function name.
Changing the code to the following will work:
```cpp
diag(MatchedDecl->getLocation(), "function %0 is insufficiently awesome")
<< MatchedDecl
<< FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
diag(MatchedDecl->getLocation(), "insert 'awesome'", DiagnosticIDs::Note);
```
I'm not sure why but I think the reason for this is that the FixItHint comes after a `DiagnosticsIDs::Note` which possibly prevents fixes afterwards. Also removing the last line altogether might work, but I'm not sure how the mainteners want this to look like.
I hope I didn't break too many rules, this is my first time posting, was trying to understand why this isn't working for way too long
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVV2v4jYQ_TXmZQQKDh_hIQ93oahIbVXtSx-vHGeSTHFsZE_Izb-v7MC9u6uqHy-7CIHkeM6cM-fAqBCotYil2H4S29NCDdw5X37G-ne07UB2nWWLytVT-UeHFrhDELtM1fWrxfFVd6ivq9skdhkE7enGQAHI3t0Va2AH2qNiBAUWR7grS8Yo0ENg14M2yrZLpnqChCPkMeE3zhg3km1BuxojIPbEjDWQDVRjupQqwN3R-3jUDFYzOSvyF5GdRPb83GXzW99u8wnUpFohi18V6w7rE2qzFPlP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