r209679 - Add range accessors for captures of a LambdaExpr.
James Dennett
jdennett at google.com
Tue May 27 12:13:04 PDT 2014
Author: jdennett
Date: Tue May 27 14:13:04 2014
New Revision: 209679
URL: http://llvm.org/viewvc/llvm-project?rev=209679&view=rev
Log:
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
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/ExprCXX.cpp
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=209679&r1=209678&r2=209679&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue May 27 14:13:04 2014
@@ -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;
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=209679&r1=209678&r2=209679&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Tue May 27 14:13:04 2014
@@ -1030,6 +1030,10 @@ LambdaExpr::capture_iterator LambdaExpr:
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:
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:
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?");
More information about the cfe-commits
mailing list