================ @@ -17658,8 +17662,49 @@ HandleImmediateInvocations(Sema &SemaRef, } } +static void setContextDecl(Sema &S, Decl *Base, Decl *ContextDecl) { + switch (Base->getKind()) { + case Decl::CXXRecord: { + auto *RD = cast<CXXRecordDecl>(Base); + RD->setLambdaContextDecl(ContextDecl); + S.handleLambdaNumbering(RD, RD->getLambdaCallOperator(), + /*NumberingOverride=*/std::nullopt, + /*InSignature=*/true); + } break; + case Decl::RequiresExprBody: + cast<RequiresExprBodyDecl>(Base)->setContextDecl(ContextDecl); + break; + default: + llvm_unreachable("Undexpected Decl Kind"); + } +} + +void Sema::UpdateCurrentContextDecl(Decl *ContextDecl) { + assert(ContextDecl); + ExpressionEvaluationContextRecord &Rec = ExprEvalContexts.back(); + assert(!Rec.ContextDecl.hasValue()); + assert(Rec.LazyContextDeclPos <= PendingLazyContextDecls.size()); + Rec.ContextDecl = ContextDecl; + while (PendingLazyContextDecls.size() > Rec.LazyContextDeclPos) + setContextDecl(*this, PendingLazyContextDecls.pop_back_val(), ContextDecl); +} + void Sema::PopExpressionEvaluationContext() { ExpressionEvaluationContextRecord& Rec = ExprEvalContexts.back(); + assert(Rec.LazyContextDeclPos <= PendingLazyContextDecls.size()); + if (!Rec.HasReusedDeclContext) { + if (Rec.ContextDecl.hasValue()) { + assert(Rec.LazyContextDeclPos == PendingLazyContextDecls.size()); ---------------- mizvekov wrote:
Yeah that's basically it. If we have already created the parent, we shouldn't be using the Pending list at all. If this originally started as a lazy context, then we are in a state where we know the parent, so we should have already handled and emptied the lazy list, and shouldn't be adding new stuff to it anymore. https://github.com/llvm/llvm-project/pull/107942 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits