From: Faisal Vali Date: Tue, 12 Nov 2013 01:40:44 +0000 (+0000) Subject: REFACTOR: Have PushLambdaScope return the LambdaScopeInfo that it creates. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d78d6591fa2556b037d3571fde3631d0243c08d7;p=clang REFACTOR: Have PushLambdaScope return the LambdaScopeInfo that it creates. No Functionality change. This refactoring avoids having to call getCurLambda right after PushLambdaScope, to obtain the LambdaScopeInfo that was created during the call to PushLambdaScope. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194438 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 9de73c9ec0..19cef42436 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -960,7 +960,7 @@ public: void PushFunctionScope(); void PushBlockScope(Scope *BlockScope, BlockDecl *Block); - void PushLambdaScope(); + sema::LambdaScopeInfo *PushLambdaScope(); /// \brief This is used to inform Sema what the current TemplateParameterDepth /// is during Parsing. Currently it is used to pass on the depth diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 41f72a68a3..6fe9fb58db 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -1029,8 +1029,10 @@ void Sema::PushBlockScope(Scope *BlockScope, BlockDecl *Block) { BlockScope, Block)); } -void Sema::PushLambdaScope() { - FunctionScopes.push_back(new LambdaScopeInfo(getDiagnostics())); +LambdaScopeInfo* Sema::PushLambdaScope() { + LambdaScopeInfo *const LSI = new LambdaScopeInfo(getDiagnostics()); + FunctionScopes.push_back(LSI); + return LSI; } void Sema::RecordParsingTemplateParameterDepth(unsigned Depth) { diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 0f6818cf5a..9281951a81 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9434,8 +9434,8 @@ Sema::CheckForFunctionRedefinition(FunctionDecl *FD, static void RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator, Sema &S) { CXXRecordDecl *const LambdaClass = CallOperator->getParent(); - S.PushLambdaScope(); - LambdaScopeInfo *LSI = S.getCurLambda(); + + LambdaScopeInfo *LSI = S.PushLambdaScope(); LSI->CallOperator = CallOperator; LSI->Lambda = LambdaClass; LSI->ReturnType = CallOperator->getResultType(); diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 52f647083a..4b70e702b6 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -8276,8 +8276,7 @@ template ExprResult TreeTransform::TransformLambdaExpr(LambdaExpr *E) { - getSema().PushLambdaScope(); - LambdaScopeInfo *LSI = getSema().getCurLambda(); + LambdaScopeInfo *LSI = getSema().PushLambdaScope(); // Transform the template parameters, and add them to the current // instantiation scope. The null case is handled correctly. LSI->GLTemplateParameterList = getDerived().TransformTemplateParameterList(