[clang] b62f5fb - [Clang][Sema] Narrow inline namespace filtration for unqualified friend declarations

Troy Johnson via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 10 08:35:47 PDT 2022


Author: Troy Johnson
Date: 2022-10-10T08:34:14-07:00
New Revision: b62f5fb64edec7f5917a233bf0a9a30e1e4b70f0

URL: https://github.com/llvm/llvm-project/commit/b62f5fb64edec7f5917a233bf0a9a30e1e4b70f0
DIFF: https://github.com/llvm/llvm-project/commit/b62f5fb64edec7f5917a233bf0a9a30e1e4b70f0.diff

LOG: [Clang][Sema] Narrow inline namespace filtration for unqualified friend declarations

rG04ba1856 introduced a call to FilterLookupForScope that is expensive
for very large translation units where it was observed to cause a 6%
compile time degradation. As the comment states, the only effect is to
"remove declarations found in inline namespaces for friend declarations
with unqualified names." This change limits the call to that scenario.
The test that was added by rG04ba1856 continues to pass, but the
observed degradation is cut in half.

Differential Revision: https://reviews.llvm.org/D135370

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index b50ed6478e4b..dfae70209210 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2273,9 +2273,11 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
     // Filter out previous declarations that don't match the scope. The only
     // effect this has is to remove declarations found in inline namespaces
     // for friend declarations with unqualified names.
-    SemaRef.FilterLookupForScope(Previous, DC, /*Scope*/ nullptr,
-                                 /*ConsiderLinkage*/ true,
-                                 QualifierLoc.hasQualifier());
+    if (isFriend && !QualifierLoc && !FunctionTemplate) {
+      SemaRef.FilterLookupForScope(Previous, DC, /*Scope=*/ nullptr,
+                                   /*ConsiderLinkage=*/ true,
+                                   QualifierLoc.hasQualifier());
+    }
   }
 
   // Per [temp.inst], default arguments in function declarations at local scope


        


More information about the cfe-commits mailing list