[clang] [clang] Speed up Decl::getASTContext() (PR #226612)
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 30 03:10:56 PDT 2026
================
@@ -548,7 +548,15 @@ TranslationUnitDecl *Decl::getTranslationUnitDecl() {
}
ASTContext &Decl::getASTContext() const {
- return getTranslationUnitDecl()->getASTContext();
+ if (const auto *TUD = dyn_cast<TranslationUnitDecl>(this))
+ return TUD->getASTContext();
----------------
zmodem wrote:
Could you move the cache check first, and skip this type check on the fast path?
https://github.com/llvm/llvm-project/pull/226612
More information about the cfe-commits
mailing list