[clang] [ASTMatchers] Reduce per-matcher, per-node traversal kind overhead (PR #228960)

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 5 06:50:05 PDT 2026


================
@@ -873,7 +874,11 @@ class ASTContext : public RefCountedBase<ASTContext> {
   };
 
   /// Returns the dynamic AST node parent map context.
-  ParentMapContext &getParentMapContext();
+  ParentMapContext &getParentMapContext() {
+    if (LLVM_LIKELY(ParentMapCtx))
+      return *ParentMapCtx;
+    return createParentMapContext();
----------------
nico wrote:

Inlining the creation doesn't work since ParentMapContext is incomplete in ASTContext.h. But constructing it eagerly seems fine, so switched to that.

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


More information about the cfe-commits mailing list