diff options
author | Ben Langmuir <ben.langmuir@intel.com> | 2013-05-03 19:00:33 +0000 |
---|---|---|
committer | Ben Langmuir <ben.langmuir@intel.com> | 2013-05-03 19:00:33 +0000 |
commit | 8c045ace381972f41d385b0a661ccf172834f459 (patch) | |
tree | 76127b79e1f24f48fd5b6cf66dd8952be22c8a0a /lib/Sema/SemaStmt.cpp | |
parent | 4761b102de0defef110d760ff77bfc367eac93c9 (diff) |
Move CapturedStmt parameters to CapturedDecl
Move the creation of CapturedStmt parameters out of CodeGen and into
Sema, making it easier to customize the outlined function. The
ImplicitParamDecls are stored in the CapturedDecl using an
ASTContext-allocated array.
Differential Revision: http://llvm-reviews.chandlerc.com/D722
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181043 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
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); |