Index: cfe/trunk/include/clang/AST/ExprCXX.h =================================================================== --- cfe/trunk/include/clang/AST/ExprCXX.h +++ cfe/trunk/include/clang/AST/ExprCXX.h @@ -1426,6 +1426,12 @@ /// both implicit and explicit. typedef const Capture *capture_iterator; + /// \brief An iterator over a range of lambda captures. + typedef llvm::iterator_range 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 @@ /// \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 @@ /// 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: cfe/trunk/lib/AST/ExprCXX.cpp =================================================================== --- cfe/trunk/lib/AST/ExprCXX.cpp +++ cfe/trunk/lib/AST/ExprCXX.cpp @@ -1030,6 +1030,10 @@ 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 @@ 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 @@ return capture_end(); } +LambdaExpr::capture_range LambdaExpr::implicit_captures() const { + return capture_range(implicit_capture_begin(), implicit_capture_end()); +} + ArrayRef LambdaExpr::getCaptureInitIndexVars(capture_init_iterator Iter) const { assert(HasArrayIndexVars && "No array index-var data?");