diff options
| author | James Dennett <jdennett@google.com> | 2014-05-27 19:13:04 +0000 |
|---|---|---|
| committer | James Dennett <jdennett@google.com> | 2014-05-27 19:13:04 +0000 |
| commit | 1575cb49cd87b8abf87ae5a866c2a3f49abf9158 (patch) | |
| tree | e3071ce77139b845cceb04214fc58757237413de | |
| parent | e41db2fe31d3c7d4656ff2e84830ce2f0a7645b9 (diff) | |
| download | bcm5719-llvm-1575cb49cd87b8abf87ae5a866c2a3f49abf9158.tar.gz bcm5719-llvm-1575cb49cd87b8abf87ae5a866c2a3f49abf9158.zip | |
Add range accessors for captures of a LambdaExpr.
Summary:
This adds LambdaExpr::captures(), LambdaExpr::explicit_captures()
and LambdaExpr::implicit_captures() as simple wrappers over the underlying
*_begin()/*_end() functions.
Reviewers: aaron.ballman
Differential Revision: http://reviews.llvm.org/D3926
llvm-svn: 209679
| -rw-r--r-- | clang/include/clang/AST/ExprCXX.h | 12 | ||||
| -rw-r--r-- | clang/lib/AST/ExprCXX.cpp | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index d641442f0a1..4403b0858fc 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -1426,6 +1426,12 @@ public: /// both implicit and explicit. typedef const Capture *capture_iterator; + /// \brief An iterator over a range of lambda captures. + typedef llvm::iterator_range<capture_iterator> capture_range; + + /// \brief Retrieve this lambda's captures. + capture_range captures() const; + /// \brief Retrieve an iterator pointing to the first lambda capture. capture_iterator capture_begin() const; @@ -1435,6 +1441,9 @@ public: /// \brief Determine the number of captures in this lambda. unsigned capture_size() const { return NumCaptures; } + + /// \brief Retrieve this lambda's explicit captures. + capture_range explicit_captures() const; /// \brief Retrieve an iterator pointing to the first explicit /// lambda capture. @@ -1444,6 +1453,9 @@ public: /// explicit lambda captures. capture_iterator explicit_capture_end() const; + /// \brief Retrieve this lambda's implicit captures. + capture_range implicit_captures() const; + /// \brief Retrieve an iterator pointing to the first implicit /// lambda capture. capture_iterator implicit_capture_begin() const; diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index d6002a7824a..1c906789ab7 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -1030,6 +1030,10 @@ LambdaExpr::capture_iterator LambdaExpr::capture_end() const { return capture_begin() + NumCaptures; } +LambdaExpr::capture_range LambdaExpr::captures() const { + return capture_range(capture_begin(), capture_end()); +} + LambdaExpr::capture_iterator LambdaExpr::explicit_capture_begin() const { return capture_begin(); } @@ -1040,6 +1044,10 @@ LambdaExpr::capture_iterator LambdaExpr::explicit_capture_end() const { return Data.Captures + Data.NumExplicitCaptures; } +LambdaExpr::capture_range LambdaExpr::explicit_captures() const { + return capture_range(explicit_capture_begin(), explicit_capture_end()); +} + LambdaExpr::capture_iterator LambdaExpr::implicit_capture_begin() const { return explicit_capture_end(); } @@ -1048,6 +1056,10 @@ LambdaExpr::capture_iterator LambdaExpr::implicit_capture_end() const { return capture_end(); } +LambdaExpr::capture_range LambdaExpr::implicit_captures() const { + return capture_range(implicit_capture_begin(), implicit_capture_end()); +} + ArrayRef<VarDecl *> LambdaExpr::getCaptureInitIndexVars(capture_init_iterator Iter) const { assert(HasArrayIndexVars && "No array index-var data?"); |

