[clang] [Clang] Cache AST context lookup for declarations (NFC) (PR #223047)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 28 02:47:55 PDT 2026


zmodem wrote:

(I came here via https://github.com/llvm/llvm-project/pull/226612 but it seems most of the discussion is happening here.)

I'd be happy to see either of these land, but stepping back further (to 2009: 743e7db794ab552684504739d0afbf98199bef18): I guess we added the reference from the AST to the ASTContext as a convenience, even though it seems a bit redundant. Adding caches in the DeclContexts seems even more redundant. Code that works with the AST (notably Sema) already knows the ASTContext, so instead of looking it up all the time, couldn't we use it directly more? Maybe it's time to bring back the ASTContext argument to Decl::getAttrs() etc?

https://github.com/llvm/llvm-project/pull/223047


More information about the cfe-commits mailing list