[clang] 87ba95a - [NFC] Don't recompute Linkage for Decl in Release Modes

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 9 23:24:02 PST 2023


Author: Chuanqi Xu
Date: 2023-03-10T15:23:38+08:00
New Revision: 87ba95aa212a4fd363a4dd52677e9eea5224a4e7

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

LOG: [NFC] Don't recompute Linkage for Decl in Release Modes

In the assertion enabled mode we will test if the computed linkage of
Declaration is consistent with the cached linkage. But we shouldn't
compuate it if we have cached linkage in the release modes.

Added: 
    

Modified: 
    clang/lib/AST/Decl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 240e744ee644..06af1969a8f0 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1525,11 +1525,16 @@ LinkageInfo LinkageComputer::getLVForDecl(const NamedDecl *D,
   if (std::optional<LinkageInfo> LI = lookup(D, computation))
     return *LI;
 
+#ifndef NDEBUG
   LinkageInfo LV = computeLVForDecl(D, computation);
   if (D->hasCachedLinkage())
     assert(D->getCachedLinkage() == LV.getLinkage());
 
   D->setCachedLinkage(LV.getLinkage());
+#else
+  LinkageInfo LV = D->hasCachedLinkage() ? D->getCachedLinkage() :
+                   computeLVForDecl(D, computation);
+#endif
   cache(D, computation, LV);
 
 #ifndef NDEBUG


        


More information about the cfe-commits mailing list