[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 6 04:37:24 PDT 2024
================
@@ -2379,23 +2379,32 @@ Sema::LambdaScopeForCallOperatorInstantiationRAII::
SemaRef.RebuildLambdaScopeInfo(cast<CXXMethodDecl>(FD));
- FunctionDecl *Pattern = getPatternFunctionDecl(FD);
- if (Pattern) {
- SemaRef.addInstantiatedCapturesToScope(FD, Pattern, Scope, MLTAL);
+ FunctionDecl *FDPattern = getPatternFunctionDecl(FD);
+ if (!FDPattern)
+ return;
- FunctionDecl *ParentFD = FD;
- while (ShouldAddDeclsFromParentScope) {
+ SemaRef.addInstantiatedCapturesToScope(FD, FDPattern, Scope, MLTAL);
- ParentFD =
- dyn_cast<FunctionDecl>(getLambdaAwareParentOfDeclContext(ParentFD));
- Pattern =
- dyn_cast<FunctionDecl>(getLambdaAwareParentOfDeclContext(Pattern));
+ if (!ShouldAddDeclsFromParentScope)
+ return;
- if (!ParentFD || !Pattern)
- break;
+ llvm::SmallVector<std::pair<FunctionDecl *, FunctionDecl *>, 4>
+ ParentInstantiations;
+ std::pair<FunctionDecl *, FunctionDecl *> Current = {FDPattern, FD};
+ while (true) {
+ Current.first = dyn_cast<FunctionDecl>(
+ getLambdaAwareParentOfDeclContext(Current.first));
+ Current.second = dyn_cast<FunctionDecl>(
+ getLambdaAwareParentOfDeclContext(Current.second));
----------------
zyn0217 wrote:
Using `.first` and `.second` seems a bit unclear. Can we wrap them into a local struct?
https://github.com/llvm/llvm-project/pull/97215
More information about the cfe-commits
mailing list