[clang] [Clang] Cache AST context lookup for declarations (NFC) (PR #223047)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 11:56:59 PDT 2026
================
@@ -1488,6 +1484,18 @@ DeclContext *DeclContext::getNonTransparentContext() {
return DC;
}
+ASTContext &DeclContext::getParentASTContextSlow() const {
+ const DeclContext *DC = this;
+ while (!DC->isTranslationUnit()) {
----------------
efriedma-quic wrote:
We might as well just past the ASTContext into the DeclContext constructor; should be simple to implement, and makes things slightly faster if we can skip doing a null check.
------
My primary concern with this patch is that this is sort of an irreversible decision; if we start assuming the ASTContext is always available cheaply from a DeclContext, we'll never be able go the other way. But I guess we might already be at that point.
https://github.com/llvm/llvm-project/pull/223047
More information about the cfe-commits
mailing list