[clang-tools-extra] 497a754 - [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804
Adam Balogh via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 1 23:51:12 PST 2019
Author: Adam Balogh
Date: 2019-12-02T08:50:51+01:00
New Revision: 497a754adeca67196c12a936d09c12d6803f99de
URL: https://github.com/llvm/llvm-project/commit/497a754adeca67196c12a936d09c12d6803f99de
DIFF: https://github.com/llvm/llvm-project/commit/497a754adeca67196c12a936d09c12d6803f99de.diff
LOG: [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804
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.
Differential Revision: https://reviews.llvm.org/D70850
Added:
Modified:
clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
index 7ca5c1e3454b..8d4366b51a3e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
@@ -54,7 +54,7 @@ static bool isSurroundedRight(const Token &T) {
/// 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.
diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
index 2cc45e83b203..8d128352e789 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
+++ b/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
More information about the cfe-commits
mailing list