[PATCH] D20853: [clang-tidy] misc-macro-parentheses: Don't insert parentheses in variable declarations. Fixes bugzilla 26273

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 3 14:43:29 PDT 2016


alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with a few style comments.


================
Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:82
@@ +81,3 @@
+
+  // If we see int/short/struct etc just assume this is a variable declaration
+  if (isVarDeclKeyword(*Tok))
----------------
Either `If we see int/short/struct/etc., ` or `If we see int, short, struct, etc., `.
Please also add a trailing period.  

================
Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:86
@@ +85,3 @@
+
+  // Variable declarations start with identifier or coloncolon
+  if (!Tok->isOneOf(tok::identifier, tok::raw_identifier, tok::coloncolon))
----------------
Trailing period, please.

================
Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:93
@@ +92,3 @@
+      Tok != MI->tokens_end() &&
+      (Tok->isOneOf(tok::identifier, tok::raw_identifier, tok::coloncolon,
+                    tok::star, tok::amp, tok::ampamp, tok::less, tok::greater)))
----------------
Please remove parentheses around the method call.

================
Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:97
@@ +96,3 @@
+
+  // Return true for possible variable declarations
+  return Tok == MI->tokens_end() ||
----------------
Trailing period.

================
Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:105
@@ -71,1 +104,3 @@
                                                   const MacroInfo *MI) {
+  // Make sure macro replacement isn't a variable declaration
+  if (possibleVarDecl(MI, MI->tokens_begin()))
----------------
Trailing period.

================
Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:158
@@ +157,3 @@
+  
+  // Skip variable declaration
+  bool VarDecl = possibleVarDecl(MI, MI->tokens_begin());
----------------
ditto


Repository:
  rL LLVM

http://reviews.llvm.org/D20853





More information about the cfe-commits mailing list