[clang] [clang-tools-extra] [llvm] [clang] WIP: Improved Context Declaration tracking (PR #107942)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 6 00:44:32 PST 2024
================
@@ -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
More information about the cfe-commits
mailing list