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

llvm-svn: 181043
This commit is contained in:
Ben Langmuir
2013-05-03 19:00:33 +00:00
parent 231ca1c929
commit 37943a7af8
7 changed files with 65 additions and 17 deletions

View File

@@ -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);