[clang-tools-extra] [clang-tidy] add check to suggest replacement of nested std::min or std::max with initializer lists (PR #85572)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 29 12:50:58 PDT 2024
sopyb wrote:
Hey there, I've hit a bit of a wall. I'm trying to figure out if a location is inside a comment. The check generates faulty diagnostics, as it is now, if there are comments including '(', '{', '}', and ','. If I could check if the match is inside a comment this issue could be fixed in a few lines of code. I spent all day looking around [doxygen](https://clang.llvm.org/doxygen/) and trying out stuff but nothing seems to work. Here's an example of faulty code:
```cpp
std::min(
std::min/*some comment containing (*/(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// comment containing {
~
{
4,
5
// some comment containing }
~
},
// some comment containing ,
~
CmpFunc
~~~~~~~ (as intended)
),
~
1,
CmpFunc);
```
so the output is
```cpp
std::min(
*/(
// comment containing
{
4,
5
// some comment containing
},
// some comment containing
,
1,
CmpFunc);
```
https://github.com/llvm/llvm-project/pull/85572
More information about the cfe-commits
mailing list