================ @@ -247,18 +242,23 @@ getGenericLambdaTemplateParameterList(LambdaScopeInfo *LSI, Sema &SemaRef) { CXXRecordDecl * Sema::createLambdaClosureType(SourceRange IntroducerRange, TypeSourceInfo *Info, - unsigned LambdaDependencyKind, - LambdaCaptureDefault CaptureDefault) { + LambdaCaptureDefault CaptureDefault, + unsigned TemplateDepth) { DeclContext *DC = CurContext; - while (!(DC->isFunctionOrMethod() || DC->isRecord() || DC->isFileContext())) - DC = DC->getParent(); bool IsGenericLambda = Info && getGenericLambdaTemplateParameterList(getCurLambda(), *this); // Start constructing the lambda class. + ContextDeclOrLazy ContextDecl = currentEvaluationContext().ContextDecl; CXXRecordDecl *Class = CXXRecordDecl::CreateLambda( - Context, DC, Info, IntroducerRange.getBegin(), LambdaDependencyKind, - IsGenericLambda, CaptureDefault); + Context, DC, Info, IntroducerRange.getBegin(), IsGenericLambda, + CaptureDefault, + ContextDecl.hasValue() ? *ContextDecl + : ContextDeclOrSentinel(TemplateDepth), + currentEvaluationContext().ContextArgs); + if (!ContextDecl.hasValue()) ---------------- zyn0217 wrote:
I find it more likely for one to conflate the semantics of `hasValue()` with those of `operator bool` whereas the latter actually indicates whether this is in a null state (i.e. neither the pointer nor the depth is assigned). For clarity, could we rename it to something more descriptive, like `hasDeclPointer()`? 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