llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: Zeyi Xu (zeyi2) <details> <summary>Changes</summary> Fixes #<!-- -->219922. --- Full diff: https://github.com/llvm/llvm-project/pull/219955.diff 3 Files Affected: - (modified) clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp (+1-1) - (modified) clang-tools-extra/docs/ReleaseNotes.md (+4) - (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/macro-parentheses.cpp (+10) ``````````diff diff --git a/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp index a51bce1484a42..1de723cb87b5b 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp @@ -53,7 +53,7 @@ static bool isSurroundedRight(const Token &T) { static bool isKeyword(const Token &T) { // FIXME: better matching of keywords to avoid false positives. return T.isOneOf(tok::kw_if, tok::kw_case, tok::kw_const, tok::kw_volatile, - tok::kw_struct); + tok::kw_struct, tok::kw_using); } /// Warning is written when one of these operators are not within parentheses. diff --git a/clang-tools-extra/docs/ReleaseNotes.md b/clang-tools-extra/docs/ReleaseNotes.md index 633418a2abb98..cb7e957737f71 100644 --- a/clang-tools-extra/docs/ReleaseNotes.md +++ b/clang-tools-extra/docs/ReleaseNotes.md @@ -135,6 +135,10 @@ infrastructure are described first, followed by tool-specific sections. instead of forcing a signed type, when a multiplication of two unsigned operands narrower than `int` is only signed due to integer promotion. +- Improved {doc}`bugprone-macro-parentheses + <clang-tidy/checks/bugprone/macro-parentheses>` by fixing invalid fixes for + macro arguments used as names in alias declarations. + - Fixed a crash in {doc}`bugprone-misplaced-operator-in-strlen-in-alloc <clang-tidy/checks/bugprone/misplaced-operator-in-strlen-in-alloc>` when checking an array new expression without a size expression. 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 a3ce47d3d0885..3900801adb362 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 @@ -14,6 +14,8 @@ // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses] #define BAD7(x, y) if (x) goto y; else x; // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses] +#define BAD8(name, x) using name = decltype(x + 1) +// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: macro argument should be enclosed in parentheses #define GOOD1 1 #define GOOD2 (1+2) @@ -51,6 +53,14 @@ #define GOOD34(x, y) if (x) goto y; #define GOOD35(x, y) if (x) goto *(y); +struct something {}; +#define GOOD36(name) using name = something +#define GOOD37(name) using name = something & +#define GOOD38(name) using name = decltype(#name) +GOOD36(foo); +GOOD37(bar); +GOOD38(baz); + // These are allowed for now.. #define MAYBE1 *12.34 #define MAYBE2 <<3 `````````` </details> https://github.com/llvm/llvm-project/pull/219955 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
