[PATCH] D70850: [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 1 23:57:05 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG497a754adeca: [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804 (authored by baloghadamsoftware).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70850/new/

https://reviews.llvm.org/D70850

Files:
  clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
@@ -43,6 +43,7 @@
 #define GOOD30(args...)   std::cout << args;
 #define GOOD31(X)         A*X=2
 #define GOOD32(X)         std::vector<X>
+#define GOOD33(x)         if (!a__##x) a_##x = &f(#x)
 
 // These are allowed for now..
 #define MAYBE1            *12.34
Index: clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
@@ -54,7 +54,7 @@
 /// Is given TokenKind a keyword?
 static bool isKeyword(const Token &T) {
   // FIXME: better matching of keywords to avoid false positives.
-  return T.isOneOf(tok::kw_case, tok::kw_const, tok::kw_struct);
+  return T.isOneOf(tok::kw_if, tok::kw_case, tok::kw_const, tok::kw_struct);
 }
 
 /// Warning is written when one of these operators are not within parentheses.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70850.231643.patch
Type: text/x-patch
Size: 1232 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191202/05c83c7b/attachment-0001.bin>


More information about the cfe-commits mailing list