================
@@ -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();
+
+ // This is called a lot, e.g. for every attribute lookup. Only walk up to the
+ // TranslationUnitDecl once per DeclContext.
+ const DeclContext *DC = getDeclContext();
+ if (!DC->CachedASTContext)
----------------
erichkeane wrote:
Thats a shame, it was way cleaner to me :/ Ok, thanks for checking at it.
https://github.com/llvm/llvm-project/pull/226612
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits