[clang] [Clang] Cache stable DeclContext relationships (NFC) (PR #223047)

Mehdi Amini via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 12 08:55:06 PDT 2026


================
@@ -2101,6 +2102,17 @@ class DeclContext {
   /// another pointer.
   mutable Decl *LastDecl = nullptr;
 
+  /// A primary context whose identity cannot change. Incomplete C++ records
+  /// and contexts with mutable primary identities remain uncached.
+  /// Relaxed atomics permit cache population during concurrent read-only AST
+  /// traversal; they do not synchronize mutations to the AST itself.
+  mutable std::atomic<DeclContext *> CachedPrimaryContext = nullptr;
----------------
joker-eph wrote:

No we don't, this is also part of why it is still draft, I have a few things to fixup. But I couldn't keep track of all the diff locally, so I pushed draft PRs. I thought no one would be notified, seems like draft PRs aren't as "stealth" as I thought, sorry for taking some of your time here!

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


More information about the cfe-commits mailing list