diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-04-28 21:41:14 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-04-28 21:41:14 +0000 |
commit | 6d69e8c00bc1c5c06488e50823bd771c6fc02ced (patch) | |
tree | a7d7d9a2a41b455cd4ddfbe3e8cd9ecd110e9ca2 /clang/lib/Sema/SemaLambda.cpp | |
parent | e8da8096ece06fb2fe2ad847ad6ff61906f148db (diff) | |
download | bcm5719-llvm-6d69e8c00bc1c5c06488e50823bd771c6fc02ced.tar.gz bcm5719-llvm-6d69e8c00bc1c5c06488e50823bd771c6fc02ced.zip |
Fix assertion failure if a lambda array-capture is followed by a this capture.
llvm-svn: 236043
Diffstat (limited to 'clang/lib/Sema/SemaLambda.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLambda.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index fa67dedbf8c..8220641166b 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -818,7 +818,6 @@ VarDecl *Sema::createLambdaInitCaptureVarDecl(SourceLocation Loc, NewVD->markUsed(Context); NewVD->setInit(Init); return NewVD; - } FieldDecl *Sema::buildInitCaptureField(LambdaScopeInfo *LSI, VarDecl *Var) { @@ -1518,8 +1517,6 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, ExplicitResultType = !LSI->HasImplicitReturnType; LambdaExprNeedsCleanups = LSI->ExprNeedsCleanups; ContainsUnexpandedParameterPack = LSI->ContainsUnexpandedParameterPack; - ArrayIndexVars.swap(LSI->ArrayIndexVars); - ArrayIndexStarts.swap(LSI->ArrayIndexStarts); CallOperator->setLexicalDeclContext(Class); Decl *TemplateOrNonTemplateCallOperatorDecl = @@ -1546,12 +1543,14 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, CaptureInits.push_back(new (Context) CXXThisExpr(From.getLocation(), getCurrentThisType(), /*isImplicit=*/true)); + ArrayIndexStarts.push_back(ArrayIndexVars.size()); continue; } if (From.isVLATypeCapture()) { Captures.push_back( LambdaCapture(From.getLocation(), IsImplicit, LCK_VLAType)); CaptureInits.push_back(nullptr); + ArrayIndexStarts.push_back(ArrayIndexVars.size()); continue; } @@ -1566,6 +1565,8 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, if (InitResult.isInvalid()) return ExprError(); Init = InitResult.get(); + } else { + ArrayIndexStarts.push_back(ArrayIndexVars.size()); } CaptureInits.push_back(Init); } |