class LambdaExpr
Declaration
class LambdaExpr : public Expr, private TrailingObjects { /* full declaration omitted */ };
Description
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked later. Example: 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.
Declared at: clang/include/clang/AST/ExprCXX.h:1865
Inherits from: Expr, TrailingObjects
Member Variables
- private clang::SourceRange IntroducerRange
- The source range that covers the lambda introducer ([...]).
- private clang::SourceLocation CaptureDefaultLoc
- The source location of this lambda's capture-default ('=' or ' & ').
- private clang::SourceLocation ClosingBrace
- The location of the brace is also available by looking up the function call operator in the lambda class. However, it is stored here to improve the performance of getSourceRange(), and to avoid having to deserialize the function call operator from a module file just to determine the source range.
Inherited from Stmt:
Method Overview
- public static clang::LambdaExpr * Create(const clang::ASTContext & C, clang::CXXRecordDecl * Class, clang::SourceRange IntroducerRange, clang::LambdaCaptureDefault CaptureDefault, clang::SourceLocation CaptureDefaultLoc, bool ExplicitParams, bool ExplicitResultType, ArrayRef<clang::Expr *> CaptureInits, clang::SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack)
- public static clang::LambdaExpr * CreateDeserialized(const clang::ASTContext & C, unsigned int NumCaptures)
- private LambdaExpr(clang::Stmt::EmptyShell Empty, unsigned int NumCaptures)
- private LambdaExpr(clang::QualType T, clang::SourceRange IntroducerRange, clang::LambdaCaptureDefault CaptureDefault, clang::SourceLocation CaptureDefaultLoc, bool ExplicitParams, bool ExplicitResultType, ArrayRef<clang::Expr *> CaptureInits, clang::SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack)
- public clang::LambdaExpr::capture_iterator capture_begin() const
- public clang::LambdaExpr::capture_iterator capture_end() const
- public clang::LambdaExpr::capture_init_iterator capture_init_begin()
- public clang::LambdaExpr::const_capture_init_iterator capture_init_begin() const
- public clang::LambdaExpr::const_capture_init_iterator capture_init_end() const
- public clang::LambdaExpr::capture_init_iterator capture_init_end()
- public llvm::iterator_range<const_capture_init_iterator> capture_inits() const
- public llvm::iterator_range<capture_init_iterator> capture_inits()
- public unsigned int capture_size() const
- public clang::LambdaExpr::capture_range captures() const
- public clang::Stmt::const_child_range children() const
- public clang::Stmt::child_range children()
- public static bool classof(const clang::Stmt * T)
- public clang::LambdaExpr::capture_iterator explicit_capture_begin() const
- public clang::LambdaExpr::capture_iterator explicit_capture_end() const
- public clang::LambdaExpr::capture_range explicit_captures() const
- public clang::SourceLocation getBeginLoc() const
- public clang::Stmt * getBody() const
- public clang::CXXMethodDecl * getCallOperator() const
- public clang::LambdaCaptureDefault getCaptureDefault() const
- public clang::SourceLocation getCaptureDefaultLoc() const
- public clang::CompoundStmt * getCompoundStmtBody()
- public const clang::CompoundStmt * getCompoundStmtBody() const
- public clang::FunctionTemplateDecl * getDependentCallOperator() const
- public clang::SourceLocation getEndLoc() const
- public ArrayRef<clang::NamedDecl *> getExplicitTemplateParameters() const
- public clang::SourceRange getIntroducerRange() const
- public clang::CXXRecordDecl * getLambdaClass() const
- private clang::Stmt ** getStoredStmts()
- private clang::Stmt *const * getStoredStmts() const
- public clang::TemplateParameterList * getTemplateParameterList() const
- public clang::Expr * getTrailingRequiresClause() const
- public bool hasExplicitParameters() const
- public bool hasExplicitResultType() const
- public clang::LambdaExpr::capture_iterator implicit_capture_begin() const
- public clang::LambdaExpr::capture_iterator implicit_capture_end() const
- public clang::LambdaExpr::capture_range implicit_captures() const
- private void initBodyIfNeeded() const
- public bool isGenericLambda() const
- public bool isInitCapture(const clang::LambdaCapture * Capture) const
- public bool isMutable() const
Inherited from Expr:
- public Classify
- public ClassifyLValue
- public ClassifyModifiable
- public EvaluateAsBooleanCondition
- public EvaluateAsConstantExpr
- public EvaluateAsFixedPoint
- public EvaluateAsFloat
- public EvaluateAsInitializer
- public EvaluateAsInt
- public EvaluateAsLValue
- public EvaluateAsRValue
- public EvaluateForOverflow
- public EvaluateKnownConstInt
- public EvaluateKnownConstIntCheckOverflow
- public EvaluateWithSubstitution
- public HasSideEffects
- public IgnoreCasts
- public IgnoreCasts
- public IgnoreConversionOperatorSingleStep
- public IgnoreConversionOperatorSingleStep
- public IgnoreImpCasts
- public IgnoreImpCasts
- public IgnoreImplicit
- public IgnoreImplicit
- public IgnoreImplicitAsWritten
- public IgnoreImplicitAsWritten
- public IgnoreParenBaseCasts
- public IgnoreParenBaseCasts
- public IgnoreParenCasts
- public IgnoreParenCasts
- public IgnoreParenImpCasts
- public IgnoreParenImpCasts
- public IgnoreParenLValueCasts
- public IgnoreParenLValueCasts
- public IgnoreParenNoopCasts
- public IgnoreParenNoopCasts
- public IgnoreParens
- public IgnoreParens
- public IgnoreUnlessSpelledInSource
- public IgnoreUnlessSpelledInSource
- public classof
- public containsErrors
- public containsUnexpandedParameterPack
- public findBoundMemberType
- public getAsBuiltinConstantDeclRef
- public getBestDynamicClassType
- public getBestDynamicClassTypeExpr
- public getDependence
- public getExprLoc
- public getFPFeaturesInEffect
- public getIntegerConstantExpr
- public getObjCProperty
- public getObjectKind
- public getReferencedDeclOfCallee
- public getReferencedDeclOfCallee
- public getSourceBitField
- public getSourceBitField
- public getType
- public getValueKind
- public getValueKindForType
- public hasAnyTypeDependentArguments
- public hasNonTrivialCall
- public hasPlaceholderType
- public hasPlaceholderType
- public isBoundMemberFunction
- public isCXX11ConstantExpr
- public isCXX98IntegralConstantExpr
- public isConstantInitializer
- public isDefaultArgument
- public isEvaluatable
- public isGLValue
- public isImplicitCXXThis
- public isInstantiationDependent
- public isIntegerConstantExpr
- public isKnownToHaveBooleanValue
- public isLValue
- public isModifiableLvalue
- public isNullPointerConstant
- public isOBJCGCCandidate
- public isObjCSelfExpr
- public isOrdinaryOrBitFieldObject
- public isPRValue
- public isPotentialConstantExpr
- public isPotentialConstantExprUnevaluated
- public isReadIfDiscardedInCPlusPlus11
- public isSameComparisonOperand
- public isTemporaryObject
- public isTypeDependent
- public isUnusedResultAWarning
- public isValueDependent
- public isXValue
- public refersToBitField
- public refersToGlobalRegisterVar
- public refersToMatrixElement
- public refersToVectorElement
- protected setDependence
- public setObjectKind
- public setType
- public setValueKind
- public skipRValueSubobjectAdjustments
- public skipRValueSubobjectAdjustments
- public tryEvaluateObjectSize
- public tryEvaluateStrLen
Inherited from ValueStmt:
Inherited from Stmt:
- public EnableStatistics
- public IgnoreContainers
- public IgnoreContainers
- public PrintStats
- public ProcessODRHash
- public Profile
- public addStmtClass
- public child_begin
- public child_begin
- public child_end
- public child_end
- public children
- public children
- public determineLikelihoodConflict
- public dump
- public dump
- public dumpColor
- public dumpPretty
- public getBeginLoc
- public getEndLoc
- public getID
- public getLikelihood
- public getLikelihood
- public getLikelihood
- public getLikelihoodAttr
- public getSourceRange
- public getStmtClass
- public getStmtClassName
- public printJson
- public printPretty
- public printPrettyControlled
- public stripLabelLikeStatements
- public stripLabelLikeStatements
- public viewAST
Methods
¶static clang::LambdaExpr* Create(
const clang::ASTContext& C,
clang::CXXRecordDecl* Class,
clang::SourceRange IntroducerRange,
clang::LambdaCaptureDefault CaptureDefault,
clang::SourceLocation CaptureDefaultLoc,
bool ExplicitParams,
bool ExplicitResultType,
ArrayRef<clang::Expr*> CaptureInits,
clang::SourceLocation ClosingBrace,
bool ContainsUnexpandedParameterPack)
static clang::LambdaExpr* Create(
const clang::ASTContext& C,
clang::CXXRecordDecl* Class,
clang::SourceRange IntroducerRange,
clang::LambdaCaptureDefault CaptureDefault,
clang::SourceLocation CaptureDefaultLoc,
bool ExplicitParams,
bool ExplicitResultType,
ArrayRef<clang::Expr*> CaptureInits,
clang::SourceLocation ClosingBrace,
bool ContainsUnexpandedParameterPack)
Description
Construct a new lambda expression.
Declared at: clang/include/clang/AST/ExprCXX.h:1907
Parameters
- const clang::ASTContext& C
- clang::CXXRecordDecl* Class
- clang::SourceRange IntroducerRange
- clang::LambdaCaptureDefault CaptureDefault
- clang::SourceLocation CaptureDefaultLoc
- bool ExplicitParams
- bool ExplicitResultType
- ArrayRef<clang::Expr*> CaptureInits
- clang::SourceLocation ClosingBrace
- bool ContainsUnexpandedParameterPack
¶static clang::LambdaExpr* CreateDeserialized(
const clang::ASTContext& C,
unsigned int NumCaptures)
static clang::LambdaExpr* CreateDeserialized(
const clang::ASTContext& C,
unsigned int NumCaptures)
Description
Construct a new lambda expression that will be deserialized from an external source.
Declared at: clang/include/clang/AST/ExprCXX.h:1915
Parameters
- const clang::ASTContext& C
- unsigned int NumCaptures
¶LambdaExpr(clang::Stmt::EmptyShell Empty,
unsigned int NumCaptures)
LambdaExpr(clang::Stmt::EmptyShell Empty,
unsigned int NumCaptures)
Description
Construct an empty lambda expression.
Declared at: clang/include/clang/AST/ExprCXX.h:1893
Parameters
- clang::Stmt::EmptyShell Empty
- unsigned int NumCaptures
¶LambdaExpr(
clang::QualType T,
clang::SourceRange IntroducerRange,
clang::LambdaCaptureDefault CaptureDefault,
clang::SourceLocation CaptureDefaultLoc,
bool ExplicitParams,
bool ExplicitResultType,
ArrayRef<clang::Expr*> CaptureInits,
clang::SourceLocation ClosingBrace,
bool ContainsUnexpandedParameterPack)
LambdaExpr(
clang::QualType T,
clang::SourceRange IntroducerRange,
clang::LambdaCaptureDefault CaptureDefault,
clang::SourceLocation CaptureDefaultLoc,
bool ExplicitParams,
bool ExplicitResultType,
ArrayRef<clang::Expr*> CaptureInits,
clang::SourceLocation ClosingBrace,
bool ContainsUnexpandedParameterPack)
Description
Construct a lambda expression.
Declared at: clang/include/clang/AST/ExprCXX.h:1886
Parameters
- clang::QualType T
- clang::SourceRange IntroducerRange
- clang::LambdaCaptureDefault CaptureDefault
- clang::SourceLocation CaptureDefaultLoc
- bool ExplicitParams
- bool ExplicitResultType
- ArrayRef<clang::Expr*> CaptureInits
- clang::SourceLocation ClosingBrace
- bool ContainsUnexpandedParameterPack
¶clang::LambdaExpr::capture_iterator
capture_begin() const
clang::LambdaExpr::capture_iterator
capture_begin() const
Description
Retrieve an iterator pointing to the first lambda capture.
Declared at: clang/include/clang/AST/ExprCXX.h:1940
¶clang::LambdaExpr::capture_iterator capture_end()
const
clang::LambdaExpr::capture_iterator capture_end()
const
Description
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Declared at: clang/include/clang/AST/ExprCXX.h:1944
¶clang::LambdaExpr::capture_init_iterator
capture_init_begin()
clang::LambdaExpr::capture_init_iterator
capture_init_begin()
Description
Retrieve the first initialization argument for this lambda expression (which initializes the first capture field).
Declared at: clang/include/clang/AST/ExprCXX.h:1992
¶clang::LambdaExpr::const_capture_init_iterator
capture_init_begin() const
clang::LambdaExpr::const_capture_init_iterator
capture_init_begin() const
Description
Retrieve the first initialization argument for this lambda expression (which initializes the first capture field).
Declared at: clang/include/clang/AST/ExprCXX.h:1998
¶clang::LambdaExpr::const_capture_init_iterator
capture_init_end() const
clang::LambdaExpr::const_capture_init_iterator
capture_init_end() const
Description
Retrieve the iterator pointing one past the last initialization argument for this lambda expression.
Declared at: clang/include/clang/AST/ExprCXX.h:2010
¶clang::LambdaExpr::capture_init_iterator
capture_init_end()
clang::LambdaExpr::capture_init_iterator
capture_init_end()
Description
Retrieve the iterator pointing one past the last initialization argument for this lambda expression.
Declared at: clang/include/clang/AST/ExprCXX.h:2004
¶llvm::iterator_range<const_capture_init_iterator>
capture_inits() const
llvm::iterator_range<const_capture_init_iterator>
capture_inits() const
Description
Retrieve the initialization expressions for this lambda's captures.
Declared at: clang/include/clang/AST/ExprCXX.h:1986
¶llvm::iterator_range<capture_init_iterator>
capture_inits()
llvm::iterator_range<capture_init_iterator>
capture_inits()
Description
Retrieve the initialization expressions for this lambda's captures.
Declared at: clang/include/clang/AST/ExprCXX.h:1981
¶unsigned int capture_size() const
unsigned int capture_size() const
Description
Determine the number of captures in this lambda.
Declared at: clang/include/clang/AST/ExprCXX.h:1947
¶clang::LambdaExpr::capture_range captures() const
clang::LambdaExpr::capture_range captures() const
Description
Retrieve this lambda's captures.
Declared at: clang/include/clang/AST/ExprCXX.h:1937
¶clang::Stmt::const_child_range children() const
clang::Stmt::const_child_range children() const
Declared at: clang/include/clang/AST/ExprCXX.h:2088
¶clang::Stmt::child_range children()
clang::Stmt::child_range children()
Description
Includes the captures and the body of the lambda.
Declared at: clang/include/clang/AST/ExprCXX.h:2087
¶static bool classof(const clang::Stmt* T)
static bool classof(const clang::Stmt* T)
Declared at: clang/include/clang/AST/ExprCXX.h:2076
Parameters
- const clang::Stmt* T
¶clang::LambdaExpr::capture_iterator
explicit_capture_begin() const
clang::LambdaExpr::capture_iterator
explicit_capture_begin() const
Description
Retrieve an iterator pointing to the first explicit lambda capture.
Declared at: clang/include/clang/AST/ExprCXX.h:1954
¶clang::LambdaExpr::capture_iterator
explicit_capture_end() const
clang::LambdaExpr::capture_iterator
explicit_capture_end() const
Description
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Declared at: clang/include/clang/AST/ExprCXX.h:1958
¶clang::LambdaExpr::capture_range
explicit_captures() const
clang::LambdaExpr::capture_range
explicit_captures() const
Description
Retrieve this lambda's explicit captures.
Declared at: clang/include/clang/AST/ExprCXX.h:1950
¶clang::SourceLocation getBeginLoc() const
clang::SourceLocation getBeginLoc() const
Declared at: clang/include/clang/AST/ExprCXX.h:2080
¶clang::Stmt* getBody() const
clang::Stmt* getBody() const
Description
Retrieve the body of the lambda. This will be most of the time a \p CompoundStmt, but can also be \p CoroutineBodyStmt wrapping a \p CompoundStmt. Note that unlike functions, lambda-expressions cannot have a function-try-block.
Declared at: clang/include/clang/AST/ExprCXX.h:2052
¶clang::CXXMethodDecl* getCallOperator() const
clang::CXXMethodDecl* getCallOperator() const
Description
Retrieve the function call operator associated with this lambda expression.
Declared at: clang/include/clang/AST/ExprCXX.h:2028
¶clang::LambdaCaptureDefault getCaptureDefault()
const
clang::LambdaCaptureDefault getCaptureDefault()
const
Description
Determine the default capture kind for this lambda.
Declared at: clang/include/clang/AST/ExprCXX.h:1919
¶clang::SourceLocation getCaptureDefaultLoc() const
clang::SourceLocation getCaptureDefaultLoc() const
Description
Retrieve the location of this lambda's capture-default, if any.
Declared at: clang/include/clang/AST/ExprCXX.h:1924
¶clang::CompoundStmt* getCompoundStmtBody()
clang::CompoundStmt* getCompoundStmtBody()
Declared at: clang/include/clang/AST/ExprCXX.h:2058
¶const clang::CompoundStmt* getCompoundStmtBody()
const
const clang::CompoundStmt* getCompoundStmtBody()
const
Description
Retrieve the \p CompoundStmt representing the body of the lambda. This is a convenience function for callers who do not need to handle node(s) which may wrap a \p CompoundStmt.
Declared at: clang/include/clang/AST/ExprCXX.h:2057
¶clang::FunctionTemplateDecl*
getDependentCallOperator() const
clang::FunctionTemplateDecl*
getDependentCallOperator() const
Description
Retrieve the function template call operator associated with this lambda expression.
Declared at: clang/include/clang/AST/ExprCXX.h:2032
¶clang::SourceLocation getEndLoc() const
clang::SourceLocation getEndLoc() const
Declared at: clang/include/clang/AST/ExprCXX.h:2084
¶ArrayRef<clang::NamedDecl*>
getExplicitTemplateParameters() const
ArrayRef<clang::NamedDecl*>
getExplicitTemplateParameters() const
Description
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto parameter).
Declared at: clang/include/clang/AST/ExprCXX.h:2040
¶clang::SourceRange getIntroducerRange() const
clang::SourceRange getIntroducerRange() const
Description
Retrieve the source range covering the lambda introducer, which contains the explicit capture list surrounded by square brackets ([...]).
Declared at: clang/include/clang/AST/ExprCXX.h:2017
¶clang::CXXRecordDecl* getLambdaClass() const
clang::CXXRecordDecl* getLambdaClass() const
Description
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).
Declared at: clang/include/clang/AST/ExprCXX.h:2024
¶clang::Stmt** getStoredStmts()
clang::Stmt** getStoredStmts()
Declared at: clang/include/clang/AST/ExprCXX.h:1895
¶clang::Stmt* const* getStoredStmts() const
clang::Stmt* const* getStoredStmts() const
Declared at: clang/include/clang/AST/ExprCXX.h:1896
¶clang::TemplateParameterList*
getTemplateParameterList() const
clang::TemplateParameterList*
getTemplateParameterList() const
Description
If this is a generic lambda expression, retrieve the template parameter list associated with it, or else return null.
Declared at: clang/include/clang/AST/ExprCXX.h:2036
¶clang::Expr* getTrailingRequiresClause() const
clang::Expr* getTrailingRequiresClause() const
Description
Get the trailing requires clause, if any.
Declared at: clang/include/clang/AST/ExprCXX.h:2043
¶bool hasExplicitParameters() const
bool hasExplicitParameters() const
Description
Determine whether this lambda has an explicit parameter list vs. an implicit (empty) parameter list.
Declared at: clang/include/clang/AST/ExprCXX.h:2069
¶bool hasExplicitResultType() const
bool hasExplicitResultType() const
Description
Whether this lambda had its result type explicitly specified.
Declared at: clang/include/clang/AST/ExprCXX.h:2072
¶clang::LambdaExpr::capture_iterator
implicit_capture_begin() const
clang::LambdaExpr::capture_iterator
implicit_capture_begin() const
Description
Retrieve an iterator pointing to the first implicit lambda capture.
Declared at: clang/include/clang/AST/ExprCXX.h:1965
¶clang::LambdaExpr::capture_iterator
implicit_capture_end() const
clang::LambdaExpr::capture_iterator
implicit_capture_end() const
Description
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures.
Declared at: clang/include/clang/AST/ExprCXX.h:1969
¶clang::LambdaExpr::capture_range
implicit_captures() const
clang::LambdaExpr::capture_range
implicit_captures() const
Description
Retrieve this lambda's implicit captures.
Declared at: clang/include/clang/AST/ExprCXX.h:1961
¶void initBodyIfNeeded() const
void initBodyIfNeeded() const
Declared at: clang/include/clang/AST/ExprCXX.h:1898
¶bool isGenericLambda() const
bool isGenericLambda() const
Description
Whether this is a generic lambda.
Declared at: clang/include/clang/AST/ExprCXX.h:2046
¶bool isInitCapture(
const clang::LambdaCapture* Capture) const
bool isInitCapture(
const clang::LambdaCapture* Capture) const
Description
Determine whether one of this lambda's captures is an init-capture.
Declared at: clang/include/clang/AST/ExprCXX.h:1927
Parameters
- const clang::LambdaCapture* Capture
¶bool isMutable() const
bool isMutable() const
Description
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Declared at: clang/include/clang/AST/ExprCXX.h:2065