diff options
author | Wei Pan <wei.pan@intel.com> | 2013-05-04 03:59:06 +0000 |
---|---|---|
committer | Wei Pan <wei.pan@intel.com> | 2013-05-04 03:59:06 +0000 |
commit | 9fd6b8f5a73788f288edd01fa99d434d1e6588ad (patch) | |
tree | 9e9b626021de2b27472f3275c451c4d7d3e7f091 /include | |
parent | cd904e8864637e427f5ea3bf35a26e79b3dbbadf (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 'include')
-rw-r--r-- | include/clang/AST/Stmt.h | 39 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 2 |
2 files changed, 34 insertions, 7 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index da83220988..74c9ec2053 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -16,6 +16,7 @@ #include "clang/AST/DeclGroup.h" #include "clang/AST/StmtIterator.h" +#include "clang/Basic/CapturedStmt.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" @@ -1982,16 +1983,16 @@ private: /// \brief The number of variable captured, including 'this'. unsigned NumCaptures; - /// \brief The implicit outlined function. - CapturedDecl *TheCapturedDecl; + /// \brief The pointer part is the implicit the outlined function and the + /// int part is the captured region kind, 'CR_Default' etc. + llvm::PointerIntPair<CapturedDecl *, 1, CapturedRegionKind> CapDeclAndKind; /// \brief The record for captured variables, a RecordDecl or CXXRecordDecl. RecordDecl *TheRecordDecl; /// \brief Construct a captured statement. - CapturedStmt(Stmt *S, ArrayRef<Capture> Captures, - ArrayRef<Expr *> CaptureInits, - CapturedDecl *CD, RecordDecl *RD); + CapturedStmt(Stmt *S, CapturedRegionKind Kind, ArrayRef<Capture> Captures, + ArrayRef<Expr *> CaptureInits, CapturedDecl *CD, RecordDecl *RD); /// \brief Construct an empty captured statement. CapturedStmt(EmptyShell Empty, unsigned NumCaptures); @@ -2006,6 +2007,7 @@ private: public: static CapturedStmt *Create(ASTContext &Context, Stmt *S, + CapturedRegionKind Kind, ArrayRef<Capture> Captures, ArrayRef<Expr *> CaptureInits, CapturedDecl *CD, RecordDecl *RD); @@ -2020,11 +2022,36 @@ public: } /// \brief Retrieve the outlined function declaration. - CapturedDecl *getCapturedDecl() const { return TheCapturedDecl; } + CapturedDecl *getCapturedDecl() { return CapDeclAndKind.getPointer(); } + const CapturedDecl *getCapturedDecl() const { + return const_cast<CapturedStmt *>(this)->getCapturedDecl(); + } + + /// \brief Set the outlined function declaration. + void setCapturedDecl(CapturedDecl *D) { + assert(D && "null CapturedDecl"); + CapDeclAndKind.setPointer(D); + } + + /// \brief Retrieve the captured region kind. + CapturedRegionKind getCapturedRegionKind() const { + return CapDeclAndKind.getInt(); + } + + /// \brief Set the captured region kind. + void setCapturedRegionKind(CapturedRegionKind Kind) { + CapDeclAndKind.setInt(Kind); + } /// \brief Retrieve the record declaration for captured variables. const RecordDecl *getCapturedRecordDecl() const { return TheRecordDecl; } + /// \brief Set the record declaration for captured variables. + void setCapturedRecordDecl(RecordDecl *D) { + assert(D && "null RecordDecl"); + TheRecordDecl = D; + } + /// \brief True if this variable has been captured. bool capturesVariable(const VarDecl *Var) const; diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index f9475737a1..78b9f1ee5a 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -2798,7 +2798,7 @@ public: void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, unsigned NumParams); StmtResult ActOnCapturedRegionEnd(Stmt *S); - void ActOnCapturedRegionError(bool IsInstantiation = false); + void ActOnCapturedRegionError(); RecordDecl *CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams); |