[clang-tools-extra] [clang-tidy] Fix spurious errors from builtin macros in modernize-use-trailing-return-type (PR #184022)

Victor Chernyakin via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 6 13:22:53 PST 2026


================
@@ -270,8 +270,13 @@ classifyTokensBeforeFunctionName(const FunctionDecl &F, const ASTContext &Ctx,
 
       if (Info.hasMacroDefinition()) {
         const MacroInfo *MI = PP->getMacroInfo(&Info);
-        if (!MI || MI->isFunctionLike()) {
-          // Cannot handle function style macros.
+        if (!MI || MI->isFunctionLike() || MI->isBuiltinMacro()) {
+          // Cannot handle function-like macros or builtin macros.
+          // Builtin macros like __has_feature, __has_builtin, etc. are
+          // registered as object-like macros but expect function-like syntax
+          // (parenthesized arguments) when expanded. Feeding them to
+          // classifyToken() would cause the preprocessor to emit spurious
+          // "missing '(' after '...'" errors.
----------------
localspook wrote:

Maybe even remove the comment entirely? "// Cannot handle function style or builtin macros" feels like it's just repeating what the condition is already saying.

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


More information about the cfe-commits mailing list