[clang-tools-extra] [clang-tidy] Fix bugprone-macro-parentheses false positive for _Generic (PR #216237)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 24 07:14:27 PDT 2026


================
@@ -233,6 +249,11 @@ void MacroParenthesesPPCallbacks::argument(const Token &MacroNameTok,
     if (Next.is(tok::coloncolon))
       continue;
 
+    // Argument is the type-name of a C11 _Generic association.
+    if (Next.is(tok::colon) && !GenericAssocStack.empty() &&
----------------
zeyi2 wrote:

Looks like this only handles a macro parameter immediately followed by `:`?

Please add:

```
#define SELECT_PTR(expr, type) \
  _Generic((expr), type * : 1, default : 0)
```

to test file and verify that it works as expected.

https://github.com/llvm/llvm-project/pull/216237


More information about the cfe-commits mailing list