Adding a new precondition to avoid warning about array to pointer decay on system macros.
If the ImplicitCastExpr match is casting a "system header symbol" from array to pointer happens inside a system header macro, clang-tidy should not trigger a violation.
I'm calling a "system header symbol" any symbol defined in a system header, or a PredefinedExpr type (like FILE).
Since this is my first submission, there are a few things I couldn't quite figure out:
1 - There is automatic support to switching warn about violations on system header. Maybe I should reuse some of this code?
2 - This check will be supressed even if -system-headers is passed on the command line. I believe, if I reuse the code mentioned in 1, this comes for free. If not possible, I can get the configuration and change my matcher.
I could not figure out how to change the matcher dynamically though. Is there any other way than doing:
if (SystemHeaders) {
Finder->addMatcher(. ...) ;
} else {
Finder->addMatcher(..., extraPrecondition())
}
Why not match on ImplicitCastExpr rather than Stmt? Then you can remove the explicit cast below.