aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorWei Pan <wei.pan@intel.com>2013-05-04 03:59:06 +0000
committerWei Pan <wei.pan@intel.com>2013-05-04 03:59:06 +0000
commit9fd6b8f5a73788f288edd01fa99d434d1e6588ad (patch)
tree9e9b626021de2b27472f3275c451c4d7d3e7f091 /lib/Sema
parentcd904e8864637e427f5ea3bf35a26e79b3dbbadf (diff)
Implement template support for CapturedStmt
- Sema tests added and CodeGen tests are pending Differential Revision: http://llvm-reviews.chandlerc.com/D728 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181101 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaStmt.cpp15
-rw-r--r--lib/Sema/TreeTransform.h13
2 files changed, 21 insertions, 7 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 42d4590e1e..16cc43a27f 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -2981,7 +2981,8 @@ static void buildCapturedStmtCaptureList(
}
void Sema::ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
- CapturedRegionKind Kind, unsigned NumParams) {
+ CapturedRegionKind Kind,
+ unsigned NumParams) {
CapturedDecl *CD = 0;
RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, NumParams);
@@ -2996,13 +2997,10 @@ void Sema::ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
PushExpressionEvaluationContext(PotentiallyEvaluated);
}
-void Sema::ActOnCapturedRegionError(bool IsInstantiation) {
+void Sema::ActOnCapturedRegionError() {
DiscardCleanupsInEvaluationContext();
PopExpressionEvaluationContext();
- if (!IsInstantiation)
- PopDeclContext();
-
CapturedRegionScopeInfo *RSI = getCurCapturedRegion();
RecordDecl *Record = RSI->TheRecordDecl;
Record->setInvalidDecl();
@@ -3014,6 +3012,7 @@ void Sema::ActOnCapturedRegionError(bool IsInstantiation) {
ActOnFields(/*Scope=*/0, Record->getLocation(), Record, Fields,
SourceLocation(), SourceLocation(), /*AttributeList=*/0);
+ PopDeclContext();
PopFunctionScopeInfo();
}
@@ -3027,12 +3026,16 @@ StmtResult Sema::ActOnCapturedRegionEnd(Stmt *S) {
CapturedDecl *CD = RSI->TheCapturedDecl;
RecordDecl *RD = RSI->TheRecordDecl;
- CapturedStmt *Res = CapturedStmt::Create(getASTContext(), S, Captures,
+ CapturedStmt *Res = CapturedStmt::Create(getASTContext(), S,
+ RSI->CapRegionKind, Captures,
CaptureInits, CD, RD);
CD->setBody(Res->getCapturedStmt());
RD->completeDefinition();
+ DiscardCleanupsInEvaluationContext();
+ PopExpressionEvaluationContext();
+
PopDeclContext();
PopFunctionScopeInfo();
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 99cb2829bf..0fcde81d10 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -9449,7 +9449,18 @@ TreeTransform<Derived>::RebuildCXXPseudoDestructorExpr(Expr *Base,
template<typename Derived>
StmtResult
TreeTransform<Derived>::TransformCapturedStmt(CapturedStmt *S) {
- llvm_unreachable("not implement yet");
+ SourceLocation Loc = S->getLocStart();
+ unsigned NumParams = S->getCapturedDecl()->getNumParams();
+ getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/0,
+ S->getCapturedRegionKind(), NumParams);
+ StmtResult Body = getDerived().TransformStmt(S->getCapturedStmt());
+
+ if (Body.isInvalid()) {
+ getSema().ActOnCapturedRegionError();
+ return StmtError();
+ }
+
+ return getSema().ActOnCapturedRegionEnd(Body.take());
}
} // end namespace clang