[clang] [Clang] Instantiate constexpr function when they are needed. (PR #173537)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 16 06:14:48 PDT 2026


================
@@ -786,6 +797,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
   /// Keeps track of the deallocated DeclListNodes for future reuse.
   DeclListNode *ListNodeFreeList = nullptr;
 
+  std::unique_ptr<SemaProxy> SemaProxyPtr;
----------------
AaronBallman wrote:

What concerns me about this design is that it obscures which interfaces have this dependency and that information really matters.

I expect it's likely to be a large amount of work to thread this through to all the correct interfaces, but I think that design makes sense for two reasons: 1) passing it explicitly makes it very clear in the interface "this does semantic evaluation which means your AST may mutate" which is helpful for consumers of our APIs, particularly downstreams which are likely to have extensions that also need to be updated to support reflection, and 2) this makes life easier on future maintainers because someone adding an interface with this proxy signals "we need to think more deeply about what the other impacts of semantics effects are, particularly if we try to add a new parameter to existing interfaces.

I think being explicit ends up with less long-term maintenance concerns at the cost of complicating APIs and more up-front work.

WDYT?

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


More information about the cfe-commits mailing list