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

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 16 07:16:47 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;
----------------
cor3ntin wrote:

> if I call Expr::HasSideEffects() today, I don't expect that to mutate my AST out from under me. 

Sure, it won't

> If I call Expr::tryEvaluateString() I might expect that to fail instead of mutating the AST out from under me.
Similarly, `tryEvaluateString` is not evaluating in a constant context.  So it won't mutate the ast.
Now, we could set a sema proxy in all the places where `EvalInfo::InConstantContext` is set to true, but what would that gain us?


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


More information about the cfe-commits mailing list