[clang-tidy] False positive readability-redundant-parentheses when macro is present
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
~~~c++
#include
#define min(x, y) x
int f(int a, int b) {
return (std::min)(a, b);
}
~~~
~~~
:5:12: warning: redundant parentheses around expression [readability-redundant-parentheses]
5 | return (std::min)(a, b);
| ^
~~~
The suggested fix causes a compilation error, besides possibly changing the semantics.
https://godbolt.org/z/eE74Ws3fd
Contributor guide
Research direction
Start by reproducing the example with clang-tidy's readability-redundant-parentheses check, then trace the check's handling of the parenthesized std::min call when the min macro is present. Done means the diagnostic and suggested fix no longer produce a false positive or a compilation error for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100