diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/DeclCXX.h | 26 | ||||
-rw-r--r-- | include/clang/AST/ExprCXX.h | 21 | ||||
-rw-r--r-- | include/clang/Sema/ScopeInfo.h | 7 |
3 files changed, 43 insertions, 11 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 2b56871810..5487c77a3c 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -561,7 +561,8 @@ class CXXRecordDecl : public RecordDecl { typedef LambdaExpr::Capture Capture; LambdaDefinitionData(CXXRecordDecl *D) - : DefinitionData(D), NumCaptures(0), NumExplicitCaptures(0), Extra(0) { + : DefinitionData(D), NumCaptures(0), NumExplicitCaptures(0), + HasArrayIndexVars(false), Extra(0) { IsLambda = true; } @@ -569,15 +570,22 @@ class CXXRecordDecl : public RecordDecl { unsigned NumCaptures : 16; /// \brief The number of explicit captures in this lambda. - unsigned NumExplicitCaptures : 16; + unsigned NumExplicitCaptures : 15; + /// \brief Whether This lambda has any by-copy array captures, and therefore + /// has array index variables. + unsigned HasArrayIndexVars : 1; + /// \brief The "extra" data associated with the lambda, including - /// captures, capture initializers, and the body of the lambda. + /// captures, capture initializers, the body of the lambda, and the + /// array-index variables for array captures. void *Extra; /// \brief Allocate the "extra" data associated with a lambda definition. void allocateExtra(ArrayRef<Capture> Captures, ArrayRef<Expr *> CaptureInits, + ArrayRef<VarDecl *> ArrayIndexVars, + ArrayRef<unsigned> ArrayIndexStarts, Stmt *Body); /// \brief Retrieve the set of captures. @@ -588,6 +596,18 @@ class CXXRecordDecl : public RecordDecl { Stmt **getStoredStmts() const { return reinterpret_cast<Stmt **>(getCaptures() + NumCaptures); } + + /// \brief Retrieve the mapping from captures to the first array index + /// variable. + unsigned *getArrayIndexStarts() const { + return reinterpret_cast<unsigned *>(getStoredStmts() + NumCaptures + 1); + } + + /// \brief Retrieve the complete set of array-index variables. + VarDecl **getArrayIndexVars() const { + return reinterpret_cast<VarDecl **>( + getArrayIndexStarts() + NumCaptures + 1); + } }; struct DefinitionData &data() { diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 5037347773..55ad4861ab 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -1066,22 +1066,16 @@ class LambdaExpr : public Expr { /// module file just to determine the source range. SourceLocation ClosingBrace; - // Note: The Create method allocates storage after the LambdaExpr - // object, which contains the captures, followed by the capture - // initializers, and finally the body of the lambda. The capture - // initializers and lambda body are placed next to each other so - // that the children() function can visit all of them easily. - public: /// \brief Describes the capture of either a variable or 'this'. class Capture { llvm::PointerIntPair<VarDecl *, 2> VarAndBits; SourceLocation Loc; SourceLocation EllipsisLoc; - + friend class ASTStmtReader; friend class ASTStmtWriter; - + public: /// \brief Create a new capture. /// @@ -1155,6 +1149,8 @@ private: ArrayRef<Capture> Captures, bool ExplicitParams, ArrayRef<Expr *> CaptureInits, + ArrayRef<VarDecl *> ArrayIndexVars, + ArrayRef<unsigned> ArrayIndexStarts, SourceLocation ClosingBrace); public: @@ -1166,6 +1162,8 @@ public: ArrayRef<Capture> Captures, bool ExplicitParams, ArrayRef<Expr *> CaptureInits, + ArrayRef<VarDecl *> ArrayIndexVars, + ArrayRef<unsigned> ArrayIndexStarts, SourceLocation ClosingBrace); /// \brief Determine the default capture kind for this lambda. @@ -1212,6 +1210,13 @@ public: /// initialization argument for this lambda expression. capture_init_iterator capture_init_end() const; + /// \brief Retrieve the set of index variables used in the capture + /// initializer of an array captured by copy. + /// + /// \param Iter The iterator that points at the capture initializer for + /// which we are extracting the corresponding index variables. + ArrayRef<VarDecl *> getCaptureInitIndexVars(capture_init_iterator Iter) const; + /// \brief Retrieve the source range covering the lambda introducer, /// which contains the explicit capture list surrounded by square /// brackets ([...]). diff --git a/include/clang/Sema/ScopeInfo.h b/include/clang/Sema/ScopeInfo.h index 1861e958ae..57a49e6114 100644 --- a/include/clang/Sema/ScopeInfo.h +++ b/include/clang/Sema/ScopeInfo.h @@ -301,6 +301,13 @@ public: /// \brief Whether any of the capture expressions requires cleanups. bool ExprNeedsCleanups; + /// \brief Variables used to index into by-copy array captures. + llvm::SmallVector<VarDecl *, 4> ArrayIndexVars; + + /// \brief Offsets into the ArrayIndexVars array at which each capture starts + /// its list of array index variables. + llvm::SmallVector<unsigned, 4> ArrayIndexStarts; + LambdaScopeInfo(DiagnosticsEngine &Diag, CXXRecordDecl *Lambda, CXXMethodDecl *CallOperator) : CapturingScopeInfo(Diag, ImpCap_None), Lambda(Lambda), |