aboutsummaryrefslogtreecommitdiff
path: root/lib/AST
diff options
context:
space:
mode:
authorTareq A. Siraj <tareq.a.sriaj@intel.com>2013-04-16 19:37:38 +0000
committerTareq A. Siraj <tareq.a.sriaj@intel.com>2013-04-16 19:37:38 +0000
commit6afcf8875d4e447645cd7bf3733dd8e2eb8455dc (patch)
tree492ea5c7e442ea915d1f9feeafc8b24624942d96 /lib/AST
parent596eea7cc26979c952a0b177d024787a99b299df (diff)
Sema for Captured Statements
Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic analysis. Currently captures all variables by reference. TODO: templates Author: Ben Langmuir <ben.langmuir@intel.com> Differential Revision: http://llvm-reviews.chandlerc.com/D433 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179618 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST')
-rw-r--r--lib/AST/Decl.cpp4
-rw-r--r--lib/AST/DeclBase.cpp2
-rw-r--r--lib/AST/Stmt.cpp16
-rw-r--r--lib/AST/StmtPrinter.cpp2
4 files changed, 15 insertions, 9 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 36044826e8..d572335fb3 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -3234,6 +3234,10 @@ MSPropertyDecl *MSPropertyDecl::CreateDeserialized(ASTContext &C,
0, 0);
}
+CapturedDecl *CapturedDecl::Create(ASTContext &C, DeclContext *DC) {
+ return new (C) CapturedDecl(DC);
+}
+
EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD,
SourceLocation L,
IdentifierInfo *Id, QualType T,
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 3f23f3d855..402d83683a 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -553,6 +553,7 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
case StaticAssert:
case ObjCPropertyImpl:
case Block:
+ case Captured:
case TranslationUnit:
case UsingDirective:
@@ -839,6 +840,7 @@ DeclContext *DeclContext::getPrimaryContext() {
case Decl::TranslationUnit:
case Decl::LinkageSpec:
case Decl::Block:
+ case Decl::Captured:
// There is only one DeclContext for these entities.
return this;
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index e120c6a1f8..2a7b170222 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -1038,12 +1038,12 @@ CapturedStmt::Capture *CapturedStmt::getStoredCaptures() const {
CapturedStmt::CapturedStmt(Stmt *S, ArrayRef<Capture> Captures,
ArrayRef<Expr *> CaptureInits,
- FunctionDecl *FD,
+ CapturedDecl *CD,
RecordDecl *RD)
: Stmt(CapturedStmtClass), NumCaptures(Captures.size()),
- TheFuncDecl(FD), TheRecordDecl(RD) {
+ TheCapturedDecl(CD), TheRecordDecl(RD) {
assert( S && "null captured statement");
- assert(FD && "null function declaration for captured statement");
+ assert(CD && "null captured declaration for captured statement");
assert(RD && "null record declaration for captured statement");
// Copy initialization expressions.
@@ -1061,14 +1061,14 @@ CapturedStmt::CapturedStmt(Stmt *S, ArrayRef<Capture> Captures,
CapturedStmt::CapturedStmt(EmptyShell Empty, unsigned NumCaptures)
: Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
- TheFuncDecl(0), TheRecordDecl(0) {
+ TheCapturedDecl(0), TheRecordDecl(0) {
getStoredStmts()[NumCaptures] = 0;
}
CapturedStmt *CapturedStmt::Create(ASTContext &Context, Stmt *S,
ArrayRef<Capture> Captures,
ArrayRef<Expr *> CaptureInits,
- FunctionDecl *FD,
+ CapturedDecl *CD,
RecordDecl *RD) {
// The layout is
//
@@ -1089,7 +1089,7 @@ CapturedStmt *CapturedStmt::Create(ASTContext &Context, Stmt *S,
}
void *Mem = Context.Allocate(Size);
- return new (Mem) CapturedStmt(S, Captures, CaptureInits, FD, RD);
+ return new (Mem) CapturedStmt(S, Captures, CaptureInits, CD, RD);
}
CapturedStmt *CapturedStmt::CreateDeserialized(ASTContext &Context,
@@ -1106,8 +1106,8 @@ CapturedStmt *CapturedStmt::CreateDeserialized(ASTContext &Context,
}
Stmt::child_range CapturedStmt::children() {
- // Children are captured field initilizers and the statement being captured.
- return child_range(getStoredStmts(), getStoredStmts() + NumCaptures + 1);
+ // Children are captured field initilizers.
+ return child_range(getStoredStmts(), getStoredStmts() + NumCaptures);
}
bool CapturedStmt::capturesVariable(const VarDecl *Var) const {
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index 469c2846a6..1b2285c794 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -451,7 +451,7 @@ void StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
}
void StmtPrinter::VisitCapturedStmt(CapturedStmt *Node) {
- PrintStmt(Node->getCapturedStmt());
+ PrintStmt(Node->getCapturedDecl()->getBody());
}
void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {