[clang-tools-extra] r240399 - [clang-tidy] Fix false positives in misc-macro-parentheses checker

Daniel Marjamaki daniel.marjamaki at evidente.se
Tue Jun 23 05:45:14 PDT 2015


Author: danielmarjamaki
Date: Tue Jun 23 07:45:14 2015
New Revision: 240399

URL: http://llvm.org/viewvc/llvm-project?rev=240399&view=rev
Log:
[clang-tidy] Fix false positives in misc-macro-parentheses checker

Modified:
    clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
    clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp?rev=240399&r1=240398&r2=240399&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp Tue Jun 23 07:45:14 2015
@@ -148,7 +148,7 @@ void MacroParenthesesPPCallbacks::argume
       continue;
 
     // Argument is a struct member.
-    if (Prev.isOneOf(tok::period, tok::arrow))
+    if (Prev.isOneOf(tok::period, tok::arrow, tok::coloncolon))
       continue;
 
     // String concatenation.
@@ -169,8 +169,8 @@ void MacroParenthesesPPCallbacks::argume
         TI + 2 != MI->tokens_end() && (TI + 2)->is(tok::r_paren))
       continue;
 
-    // Assignment.
-    if (Prev.is(tok::equal) && Next.is(tok::semi))
+    // Assignment/return, i.e. '=x;' or 'return x;'.
+    if (Prev.isOneOf(tok::equal, tok::kw_return) && Next.is(tok::semi))
       continue;
 
     Check->diag(Tok.getLocation(), "macro argument should be enclosed in "

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp?rev=240399&r1=240398&r2=240399&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp Tue Jun 23 07:45:14 2015
@@ -30,6 +30,8 @@
 #define GOOD18(x)         ;x;
 #define GOOD19            ;-2;
 #define GOOD20            void*
+#define GOOD21(a)         case Fred::a:
+#define GOOD22(a)         if (verbose) return a;
 
 // These are allowed for now..
 #define MAYBE1            *12.34





More information about the cfe-commits mailing list