[clang] [clang-tools-extra] [llvm] [clang] WIP: Improved Context Declaration tracking (PR #107942)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 15 02:13:02 PDT 2024


================
@@ -17257,8 +17258,11 @@ void
 Sema::PushExpressionEvaluationContext(
     ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
     ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
-  Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
-  PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
+  const auto &PrevRec = ExprEvalContexts.back();
+  PushExpressionEvaluationContext(NewContext, PrevRec.ContextDecl,
+                                  PrevRec.ContextArgs, ExprContext);
+  ExprEvalContexts.back().HasReusedDeclContext = true;
+  ExprEvalContexts.back().LazyContextDeclPos = PrevRec.LazyContextDeclPos;
----------------
zyn0217 wrote:

FYI, `PrevRec` would be invalidated after `PushExpressionEvaluationContext()`, so you probably want to save the value before the call.

This caused `clang/test/SemaTemplate/stack-exhaustion.cpp` to fail on my machine.

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


More information about the cfe-commits mailing list