]> granicus.if.org Git - clang/commitdiff
Add range accessors for captures of a LambdaExpr.
authorJames Dennett <jdennett@google.com>
Tue, 27 May 2014 19:13:04 +0000 (19:13 +0000)
committerJames Dennett <jdennett@google.com>
Tue, 27 May 2014 19:13:04 +0000 (19:13 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209679 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ExprCXX.h
lib/AST/ExprCXX.cpp

index d641442f0a158650a80d4e7b1d3cf404a45a5efa..4403b0858fc8153acb6e5572d0e565b3efbf143b 100644 (file)
@@ -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;
index d6002a7824ad815df8680719c59618ae2b052bd0..1c906789ab7af8bd12b55c64db9d51affadbaaf8 100644 (file)
@@ -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?");