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:

protected

Method Overview

Inherited from Expr:

Inherited from ValueStmt:

Inherited from Stmt:

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)

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)

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)

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)

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

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

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()

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

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

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()

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

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()

Description

Retrieve the initialization expressions for this lambda's captures.

Declared at: clang/include/clang/AST/ExprCXX.h:1981

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

Description

Retrieve this lambda's captures.

Declared at: clang/include/clang/AST/ExprCXX.h:1937

clang::Stmt::const_child_range children() const

Declared at: clang/include/clang/AST/ExprCXX.h:2088

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)

Declared at: clang/include/clang/AST/ExprCXX.h:2076

Parameters

const clang::Stmt* T

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

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

Description

Retrieve this lambda's explicit captures.

Declared at: clang/include/clang/AST/ExprCXX.h:1950

clang::SourceLocation getBeginLoc() const

Declared at: clang/include/clang/AST/ExprCXX.h:2080

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

Description

Retrieve the function call operator associated with this lambda expression.

Declared at: clang/include/clang/AST/ExprCXX.h:2028

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

Description

Retrieve the location of this lambda's capture-default, if any.

Declared at: clang/include/clang/AST/ExprCXX.h:1924

clang::CompoundStmt* getCompoundStmtBody()

Declared at: clang/include/clang/AST/ExprCXX.h:2058

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

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

Declared at: clang/include/clang/AST/ExprCXX.h:2084

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

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

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()

Declared at: clang/include/clang/AST/ExprCXX.h:1895

clang::Stmt* const* getStoredStmts() const

Declared at: clang/include/clang/AST/ExprCXX.h:1896

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

Description

Get the trailing requires clause, if any.

Declared at: clang/include/clang/AST/ExprCXX.h:2043

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

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

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

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

Description

Retrieve this lambda's implicit captures.

Declared at: clang/include/clang/AST/ExprCXX.h:1961

void initBodyIfNeeded() const

Declared at: clang/include/clang/AST/ExprCXX.h:1898

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

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

Description

Determine whether the lambda is mutable, meaning that any captures values can be modified.

Declared at: clang/include/clang/AST/ExprCXX.h:2065