https://github.com/AnonMiraj created https://github.com/llvm/llvm-project/pull/237803
I noticed ParseGNUAttributes() computes the presumed location for every __attribute__ (to check if it's in a built-in) before checking if the attribute even came from a macro. Swapping the order to check the cheap macro condition first avoids this unnecessary work. it is a small speed up across the board https://llvm-compile-time-tracker.com/compare.php?from=99a148b807da7942d629fd8e807d12026fcb5e20&to=55a467c5f3d2a5c5f6bd4a08102f0893367a5478&stat=instructions%3Au >From 68867c40d2a11d340e1ba3ebf50877bbb53b4d79 Mon Sep 17 00:00:00 2001 From: Anonmiraj <[email protected]> Date: Wed, 7 Oct 2026 16:16:15 +0300 Subject: [PATCH] [clang] Check for a macro before the presumed file of an attribute --- clang/lib/Parse/ParseDecl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index e452c312702491..95e79ee32bf8a4 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -289,8 +289,8 @@ void Parser::ParseGNUAttributes(ParsedAttributes &Attrs, // If this was declared in a macro, attach the macro IdentifierInfo to the // parsed attribute. auto &SM = PP.getSourceManager(); - if (!SM.isWrittenInBuiltinFile(SM.getSpellingLoc(AttrTokLoc)) && - FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) { + if (FindLocsWithCommonFileID(PP, AttrTokLoc, Loc) && + !SM.isWrittenInBuiltinFile(SM.getSpellingLoc(AttrTokLoc))) { CharSourceRange ExpansionRange = SM.getExpansionRange(AttrTokLoc); StringRef FoundName = Lexer::getSourceText(ExpansionRange, SM, PP.getLangOpts()); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
