diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Decl.cpp | 6 | ||||
-rw-r--r-- | lib/Parse/ParsePragma.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/Sema.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 21 |
4 files changed, 24 insertions, 10 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index a431c5317e..01fbc3b2e0 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -3247,8 +3247,10 @@ MSPropertyDecl *MSPropertyDecl::CreateDeserialized(ASTContext &C, 0, 0); } -CapturedDecl *CapturedDecl::Create(ASTContext &C, DeclContext *DC) { - return new (C) CapturedDecl(DC); +CapturedDecl *CapturedDecl::Create(ASTContext &C, DeclContext *DC, + unsigned NumParams) { + unsigned Size = sizeof(CapturedDecl) + NumParams *sizeof(ImplicitParamDecl*); + return new (C.Allocate(Size)) CapturedDecl(DC, NumParams); } EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD, diff --git a/lib/Parse/ParsePragma.cpp b/lib/Parse/ParsePragma.cpp index 0ecd11ec97..ef43c5b4b7 100644 --- a/lib/Parse/ParsePragma.cpp +++ b/lib/Parse/ParsePragma.cpp @@ -136,7 +136,8 @@ StmtResult Parser::HandlePragmaCaptured() SourceLocation Loc = Tok.getLocation(); ParseScope CapturedRegionScope(this, Scope::FnScope | Scope::DeclScope); - Actions.ActOnCapturedRegionStart(Loc, getCurScope(), CR_Default); + Actions.ActOnCapturedRegionStart(Loc, getCurScope(), CR_Default, + /*NumParams=*/1); StmtResult R = ParseCompoundStatement(); CapturedRegionScope.Exit(); diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index e9a8582183..72864c5dd0 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -1316,8 +1316,8 @@ IdentifierInfo *Sema::getSuperIdentifier() const { void Sema::PushCapturedRegionScope(Scope *S, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K) { - CapturingScopeInfo *CSI = new CapturedRegionScopeInfo(getDiagnostics(), - S, CD, RD, K); + CapturingScopeInfo *CSI = new CapturedRegionScopeInfo(getDiagnostics(), S, CD, RD, + CD->getContextParam(), K); CSI->ReturnType = Context.VoidTy; FunctionScopes.push_back(CSI); } diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index f91305f072..70960faf99 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -2922,8 +2922,8 @@ StmtResult Sema::ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, } RecordDecl* -Sema::CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc) -{ +Sema::CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, + unsigned NumParams) { DeclContext *DC = CurContext; while (!(DC->isFunctionOrMethod() || DC->isRecord() || DC->isFileContext())) DC = DC->getParent(); @@ -2938,9 +2938,20 @@ Sema::CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc) RD->setImplicit(); RD->startDefinition(); - CD = CapturedDecl::Create(Context, CurContext); + CD = CapturedDecl::Create(Context, CurContext, NumParams); DC->addDecl(CD); + // Build the context parameter + assert(NumParams > 0 && "CapturedStmt requires context parameter"); + DC = CapturedDecl::castToDeclContext(CD); + IdentifierInfo *VarName = &Context.Idents.get("__context"); + QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD)); + ImplicitParamDecl *Param + = ImplicitParamDecl::Create(Context, DC, Loc, VarName, ParamType); + DC->addDecl(Param); + + CD->setContextParam(Param); + return RD; } @@ -2970,9 +2981,9 @@ static void buildCapturedStmtCaptureList( } void Sema::ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, - CapturedRegionKind Kind) { + CapturedRegionKind Kind, unsigned NumParams) { CapturedDecl *CD = 0; - RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc); + RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, NumParams); // Enter the capturing scope for this captured region. PushCapturedRegionScope(CurScope, CD, RD, Kind); |