clang API Documentation
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked later. More...
#include <ExprCXX.h>
Public Types | |
typedef const Capture * | capture_iterator |
An iterator that walks over the captures of the lambda, both implicit and explicit. | |
typedef llvm::iterator_range < capture_iterator > | capture_range |
An iterator over a range of lambda captures. | |
typedef Expr ** | capture_init_iterator |
Iterator that walks over the capture initialization arguments. | |
Public Member Functions | |
LambdaCaptureDefault | getCaptureDefault () const |
Determine the default capture kind for this lambda. | |
SourceLocation | getCaptureDefaultLoc () const |
Retrieve the location of this lambda's capture-default, if any. | |
capture_range | captures () const |
Retrieve this lambda's captures. | |
capture_iterator | capture_begin () const |
Retrieve an iterator pointing to the first lambda capture. | |
capture_iterator | capture_end () const |
Retrieve an iterator pointing past the end of the sequence of lambda captures. | |
unsigned | capture_size () const |
Determine the number of captures in this lambda. | |
capture_range | explicit_captures () const |
Retrieve this lambda's explicit captures. | |
capture_iterator | explicit_capture_begin () const |
Retrieve an iterator pointing to the first explicit lambda capture. | |
capture_iterator | explicit_capture_end () const |
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures. | |
capture_range | implicit_captures () const |
Retrieve this lambda's implicit captures. | |
capture_iterator | implicit_capture_begin () const |
Retrieve an iterator pointing to the first implicit lambda capture. | |
capture_iterator | implicit_capture_end () const |
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures. | |
llvm::iterator_range < capture_init_iterator > | capture_inits () const |
Retrieve the initialization expressions for this lambda's captures. | |
capture_init_iterator | capture_init_begin () const |
Retrieve the first initialization argument for this lambda expression (which initializes the first capture field). | |
capture_init_iterator | capture_init_end () const |
Retrieve the iterator pointing one past the last initialization argument for this lambda expression. | |
ArrayRef< VarDecl * > | getCaptureInitIndexVars (capture_init_iterator Iter) const |
Retrieve the set of index variables used in the capture initializer of an array captured by copy. | |
SourceRange | getIntroducerRange () const |
Retrieve the source range covering the lambda introducer, which contains the explicit capture list surrounded by square brackets ([...]). | |
CXXRecordDecl * | getLambdaClass () const |
Retrieve the class that corresponds to the lambda. | |
CXXMethodDecl * | getCallOperator () const |
Retrieve the function call operator associated with this lambda expression. | |
TemplateParameterList * | getTemplateParameterList () const |
If this is a generic lambda expression, retrieve the template parameter list associated with it, or else return null. | |
bool | isGenericLambda () const |
Whether this is a generic lambda. | |
CompoundStmt * | getBody () const |
Retrieve the body of the lambda. | |
bool | isMutable () const |
Determine whether the lambda is mutable, meaning that any captures values can be modified. | |
bool | hasExplicitParameters () const |
Determine whether this lambda has an explicit parameter list vs. an implicit (empty) parameter list. | |
bool | hasExplicitResultType () const |
Whether this lambda had its result type explicitly specified. | |
SourceLocation | getLocStart () const LLVM_READONLY |
SourceLocation | getLocEnd () const LLVM_READONLY |
child_range | children () |
Static Public Member Functions | |
static LambdaExpr * | Create (const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, ArrayRef< Capture > Captures, bool ExplicitParams, bool ExplicitResultType, ArrayRef< Expr * > CaptureInits, ArrayRef< VarDecl * > ArrayIndexVars, ArrayRef< unsigned > ArrayIndexStarts, SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack) |
Construct a new lambda expression. | |
static LambdaExpr * | CreateDeserialized (const ASTContext &C, unsigned NumCaptures, unsigned NumArrayIndexVars) |
Construct a new lambda expression that will be deserialized from an external source. | |
static bool | classof (const Stmt *T) |
Friends | |
class | ASTStmtReader |
class | ASTStmtWriter |
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked later.
Example:
void low_pass_filter(std::vector<double> &values, double cutoff) { values.erase(std::remove_if(values.begin(), values.end(), [=](double value) { return value > cutoff; }); }
C++11 lambda expressions can capture local variables, either by copying the values of those local variables at the time the function object is constructed (not when it is called!) or by holding a reference to the local variable. These captures can occur either implicitly or can be written explicitly between the square brackets ([...]) that start the lambda expression.
C++1y introduces a new form of "capture" called an init-capture that includes an initializing expression (rather than capturing a variable), and which can never occur implicitly.
typedef Expr** clang::LambdaExpr::capture_init_iterator |
typedef const Capture* clang::LambdaExpr::capture_iterator |
typedef llvm::iterator_range<capture_iterator> clang::LambdaExpr::capture_range |
Retrieve an iterator pointing to the first lambda capture.
Definition at line 1034 of file ExprCXX.cpp.
References getLambdaClass().
Referenced by capture_end(), captures(), explicit_capture_begin(), clang::Expr::HasSideEffects(), and clang::TreeTransform< Derived >::TransformLambdaScope().
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition at line 1038 of file ExprCXX.cpp.
References capture_begin().
Referenced by captures(), clang::Expr::HasSideEffects(), implicit_capture_end(), and clang::TreeTransform< Derived >::TransformLambdaScope().
capture_init_iterator clang::LambdaExpr::capture_init_begin | ( | ) | const [inline] |
Retrieve the first initialization argument for this lambda expression (which initializes the first capture field).
Definition at line 1503 of file ExprCXX.h.
Referenced by clang::Sema::canThrow(), capture_init_end(), capture_inits(), clang::CodeGen::CodeGenFunction::EmitLambdaExpr(), getCaptureInitIndexVars(), and clang::EvaluatedExprVisitor< ImplClass >::VisitLambdaExpr().
capture_init_iterator clang::LambdaExpr::capture_init_end | ( | ) | const [inline] |
Retrieve the iterator pointing one past the last initialization argument for this lambda expression.
Definition at line 1509 of file ExprCXX.h.
References capture_init_begin().
Referenced by clang::Sema::canThrow(), capture_inits(), clang::CodeGen::CodeGenFunction::EmitLambdaExpr(), and clang::EvaluatedExprVisitor< ImplClass >::VisitLambdaExpr().
llvm::iterator_range<capture_init_iterator> clang::LambdaExpr::capture_inits | ( | ) | const [inline] |
Retrieve the initialization expressions for this lambda's captures.
Definition at line 1496 of file ExprCXX.h.
References capture_init_begin(), and capture_init_end().
unsigned clang::LambdaExpr::capture_size | ( | ) | const [inline] |
Retrieve this lambda's captures.
Definition at line 1042 of file ExprCXX.cpp.
References capture_begin(), and capture_end().
child_range clang::LambdaExpr::children | ( | ) | [inline] |
Reimplemented from clang::Stmt.
static bool clang::LambdaExpr::classof | ( | const Stmt * | T | ) | [inline, static] |
Reimplemented from clang::Expr.
Definition at line 1557 of file ExprCXX.h.
References clang::Stmt::getStmtClass().
LambdaExpr * LambdaExpr::Create | ( | const ASTContext & | C, |
CXXRecordDecl * | Class, | ||
SourceRange | IntroducerRange, | ||
LambdaCaptureDefault | CaptureDefault, | ||
SourceLocation | CaptureDefaultLoc, | ||
ArrayRef< Capture > | Captures, | ||
bool | ExplicitParams, | ||
bool | ExplicitResultType, | ||
ArrayRef< Expr * > | CaptureInits, | ||
ArrayRef< VarDecl * > | ArrayIndexVars, | ||
ArrayRef< unsigned > | ArrayIndexStarts, | ||
SourceLocation | ClosingBrace, | ||
bool | ContainsUnexpandedParameterPack | ||
) | [static] |
Construct a new lambda expression.
Definition at line 991 of file ExprCXX.cpp.
References clang::ASTContext::Allocate(), and clang::ASTContext::getTypeDeclType().
Referenced by clang::Sema::ActOnLambdaExpr().
LambdaExpr * LambdaExpr::CreateDeserialized | ( | const ASTContext & | C, |
unsigned | NumCaptures, | ||
unsigned | NumArrayIndexVars | ||
) | [static] |
Construct a new lambda expression that will be deserialized from an external source.
Definition at line 1023 of file ExprCXX.cpp.
References clang::ASTContext::Allocate().
Retrieve an iterator pointing to the first explicit lambda capture.
Definition at line 1046 of file ExprCXX.cpp.
References capture_begin().
Referenced by explicit_captures().
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition at line 1050 of file ExprCXX.cpp.
References getLambdaClass().
Referenced by explicit_captures(), and implicit_capture_begin().
Retrieve this lambda's explicit captures.
Definition at line 1056 of file ExprCXX.cpp.
References explicit_capture_begin(), and explicit_capture_end().
CompoundStmt * LambdaExpr::getBody | ( | ) | const |
Retrieve the body of the lambda.
Definition at line 1100 of file ExprCXX.cpp.
References clang::FunctionDecl::getBody(), and getCallOperator().
Referenced by clang::TreeTransform< Derived >::TransformLambdaScope(), and clang::RecursiveASTVisitor< Derived >::TraverseLambdaBody().
CXXMethodDecl * LambdaExpr::getCallOperator | ( | ) | const |
Retrieve the function call operator associated with this lambda expression.
Definition at line 1089 of file ExprCXX.cpp.
References clang::CXXRecordDecl::getLambdaCallOperator(), getLambdaClass(), and Record.
Referenced by getBody(), and isMutable().
LambdaCaptureDefault clang::LambdaExpr::getCaptureDefault | ( | ) | const [inline] |
Determine the default capture kind for this lambda.
Definition at line 1440 of file ExprCXX.h.
Referenced by clang::TreeTransform< Derived >::TransformLambdaScope().
SourceLocation clang::LambdaExpr::getCaptureDefaultLoc | ( | ) | const [inline] |
Retrieve the location of this lambda's capture-default, if any.
Definition at line 1445 of file ExprCXX.h.
Referenced by clang::TreeTransform< Derived >::TransformLambdaScope().
ArrayRef< VarDecl * > LambdaExpr::getCaptureInitIndexVars | ( | capture_init_iterator | Iter | ) | const |
Retrieve the set of index variables used in the capture initializer of an array captured by copy.
Iter | The iterator that points at the capture initializer for which we are extracting the corresponding index variables. |
Definition at line 1073 of file ExprCXX.cpp.
References capture_init_begin(), and getLambdaClass().
Referenced by clang::CodeGen::CodeGenFunction::EmitLambdaExpr().
SourceRange clang::LambdaExpr::getIntroducerRange | ( | ) | const [inline] |
Retrieve the source range covering the lambda introducer, which contains the explicit capture list surrounded by square brackets ([...]).
Definition at line 1523 of file ExprCXX.h.
Referenced by clang::TreeTransform< Derived >::TransformLambdaScope().
CXXRecordDecl * LambdaExpr::getLambdaClass | ( | ) | const |
Retrieve the class that corresponds to the lambda.
This is the "closure type" (C++1y [expr.prim.lambda]), and stores the captures in its fields and provides the various operations permitted on a lambda (copying, calling).
Definition at line 1085 of file ExprCXX.cpp.
References clang::Type::getAsCXXRecordDecl(), and clang::Expr::getType().
Referenced by capture_begin(), clang::CodeGen::CodeGenFunction::EmitLambdaExpr(), explicit_capture_end(), getCallOperator(), getCaptureInitIndexVars(), and getTemplateParameterList().
SourceLocation clang::LambdaExpr::getLocEnd | ( | ) | const [inline] |
Reimplemented from clang::Stmt.
SourceLocation clang::LambdaExpr::getLocStart | ( | ) | const [inline] |
Reimplemented from clang::Stmt.
Definition at line 1561 of file ExprCXX.h.
References clang::SourceRange::getBegin().
Referenced by clang::TreeTransform< Derived >::TransformLambdaScope().
If this is a generic lambda expression, retrieve the template parameter list associated with it, or else return null.
Definition at line 1094 of file ExprCXX.cpp.
References clang::CXXRecordDecl::getGenericLambdaTemplateParameterList(), getLambdaClass(), and Record.
Referenced by isGenericLambda().
bool clang::LambdaExpr::hasExplicitParameters | ( | ) | const [inline] |
Determine whether this lambda has an explicit parameter list vs. an implicit (empty) parameter list.
Definition at line 1552 of file ExprCXX.h.
Referenced by clang::TreeTransform< Derived >::TransformLambdaScope().
bool clang::LambdaExpr::hasExplicitResultType | ( | ) | const [inline] |
Whether this lambda had its result type explicitly specified.
Definition at line 1555 of file ExprCXX.h.
Referenced by clang::TreeTransform< Derived >::TransformLambdaScope().
Retrieve an iterator pointing to the first implicit lambda capture.
Definition at line 1060 of file ExprCXX.cpp.
References explicit_capture_end().
Referenced by implicit_captures().
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures.
Definition at line 1064 of file ExprCXX.cpp.
References capture_end().
Referenced by implicit_captures().
Retrieve this lambda's implicit captures.
Definition at line 1068 of file ExprCXX.cpp.
References implicit_capture_begin(), and implicit_capture_end().
bool clang::LambdaExpr::isGenericLambda | ( | ) | const [inline] |
Whether this is a generic lambda.
Definition at line 1541 of file ExprCXX.h.
References getTemplateParameterList().
bool LambdaExpr::isMutable | ( | ) | const |
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition at line 1107 of file ExprCXX.cpp.
References getCallOperator(), and clang::CXXMethodDecl::isConst().
Referenced by clang::TreeTransform< Derived >::TransformLambdaScope().
friend class ASTStmtReader [friend] |
Reimplemented from clang::Stmt.
friend class ASTStmtWriter [friend] |
Reimplemented from clang::Stmt.