[PATCH] clang-tidy checker that enforce proper parentheses in macros

Alexander Kornienko alexfh at google.com
Wed Jun 3 07:15:40 PDT 2015


In http://reviews.llvm.org/D9528#182511, @danielmarjamaki wrote:

> > Did you encounter any cases when the code broke after applying fixes?
>
>
> No I did not. The projects compiled fine after the fixes.
>
> > How many instances of the warning does the latest version of the check produce on the same set of projects where you saw 47k warnings initially?
>
>
> I can't say exactly right now. It's a little less as far as I know.
>
> > I would also like to see an estimate of the false positive rate (from a random sample of 100 warnings).
>
>
> I fixed 300 warnings with -fix and saw no compiler warnings.
>
> However I looked now at 100 random warnings and saw 5 fp (for type definitions)! I can try to write a heuristic for some of those.


So the incorrect fixes in these cases were applied, but the code still compiled? Can you give a couple of examples?


================
Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:68
@@ +67,3 @@
+    } else if (Indent <= 0 &&
+               (Tok.is(tok::plus) || Tok.is(tok::minus) || Tok.is(tok::star) ||
+                Tok.is(tok::slash) || Tok.is(tok::percent) ||
----------------
danielmarjamaki wrote:
> alexfh wrote:
> > This looks like a reason to move isOneOf from clang::format::FormatToken (tools/clang/lib/Format/FormatToken.h) to clang::Token. It would greatly simplify this and similar conditions.
> Yes... I added a new patch today where this code was rewritten. I did not move isOneOf.. do you still I should do it?
The new code seems to use this pattern as well. It would be nice if you moved and used the isOneOf instead.

http://reviews.llvm.org/D9528

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list