troyj created this revision.
troyj added a reviewer: rsmith.
Herald added a project: All.
troyj requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

rG04ba1856 
<https://reviews.llvm.org/rG04ba18563390ec87400fa068a9b4981b235ebaa6> 
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 
<https://reviews.llvm.org/rG04ba18563390ec87400fa068a9b4981b235ebaa6> continues 
to pass, but the observed degradation is cut in half.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135370

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp


Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===================================================================
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2170,9 +2170,11 @@
     // 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());
+    }
   }
 
   SemaRef.CheckFunctionDeclaration(/*Scope*/ nullptr, Function, Previous,


Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===================================================================
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2170,9 +2170,11 @@
     // 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());
+    }
   }
 
   SemaRef.CheckFunctionDeclaration(/*Scope*/ nullptr, Function, Previous,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to