baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: alexfh, aaron.ballman.
baloghadamsoftware added a project: clang-tools-extra.
Herald added subscribers: mgehre, gamesh411, Szelethus, rnkovacs, xazax.hun, 
whisperity.
Herald added a project: clang.

Applying parentheses for statement leads to compilation error. Bug [[ 43804 | 
https://bugs.llvm.org/show_bug.cgi?id=43804 ]] is a compilation error suggested 
by a wrong fix of this checker. This patch is a quick fix for this issue.


Repository:
  rCTE Clang Tools Extra

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.


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.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to