Author: Chuanqi Xu
Date: 2025-08-06T10:00:03+08:00
New Revision: ee6afeb72ef2cee918c1338c926c481ad36aa915

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

LOG: [NFC] [C++20] [Modules] Lookup in cache before checking if the primary 
template is an exposure

Checking if a declaration is an exposure may be relatively expensive.
Try to use cache to avoid such checks will be helpful.

Added: 
    

Modified: 
    clang/lib/Sema/SemaModule.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index b137549b8f859..ff9f85f960d93 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -1222,7 +1222,8 @@ bool ExposureChecker::isTULocal(const NamedDecl *D) {
   // [basic.link]p15.5
   // - a specialization of a template whose (possibly instantiated) declaration
   // is an exposure.
-  if (checkExposure(PrimaryTemplate, /*Diag=*/false))
+  if (ExposureSet.count(PrimaryTemplate) ||
+      checkExposure(PrimaryTemplate, /*Diag=*/false))
     return true;
 
   // Avoid calling checkExposure again since it is expensive.


        
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to