class MaterializeTemporaryExpr

Declaration

class MaterializeTemporaryExpr : public Expr { /* full declaration omitted */ };

Description

Represents a prvalue temporary that is written into memory so that a reference can bind to it. Prvalue expressions are materialized when they need to have an address in memory for a reference to bind to. This happens when binding a reference to the result of a conversion, e.g., Here, 1.0 is implicitly converted to an \c int. That resulting \c int is then materialized via a \c MaterializeTemporaryExpr, and the reference binds to the temporary. \c MaterializeTemporaryExprs are always glvalues (either an lvalue or an xvalue, depending on the kind of reference binding to it), maintaining the invariant that references always bind to glvalues. Reference binding and copy-elision can both extend the lifetime of a temporary. When either happens, the expression will also track the declaration which is responsible for the lifetime extension.

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

Inherits from: Expr

Member Variables

private llvm::PointerUnion<Stmt*, LifetimeExtendedTemporaryDecl*> State

Inherited from Stmt:

protected

Method Overview

Inherited from Expr:

Inherited from ValueStmt:

Inherited from Stmt:

Methods

MaterializeTemporaryExpr(
    clang::Stmt::EmptyShell Empty)

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

Parameters

clang::Stmt::EmptyShell Empty

MaterializeTemporaryExpr(
    clang::QualType T,
    clang::Expr* Temporary,
    bool BoundToLvalueReference,
    clang::LifetimeExtendedTemporaryDecl* MTD =
        nullptr)

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

Parameters

clang::QualType T
clang::Expr* Temporary
bool BoundToLvalueReference
clang::LifetimeExtendedTemporaryDecl* MTD = nullptr

clang::Stmt::const_child_range children() const

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

clang::Stmt::child_range children()

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

static bool classof(const clang::Stmt* T)

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

Parameters

const clang::Stmt* T

clang::SourceLocation getBeginLoc() const

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

clang::SourceLocation getEndLoc() const

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

clang::ValueDecl* getExtendingDecl()

Description

Get the declaration which triggered the lifetime-extension of this temporary, if any.

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

const clang::ValueDecl* getExtendingDecl() const

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

clang::LifetimeExtendedTemporaryDecl*
getLifetimeExtendedTemporaryDecl()

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

const clang::LifetimeExtendedTemporaryDecl*
getLifetimeExtendedTemporaryDecl() const

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

unsigned int getManglingNumber() const

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

clang::APValue* getOrCreateValue(
    bool MayCreate) const

Description

Get the storage for the constant value of a materialized temporary of static storage duration.

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

Parameters

bool MayCreate

clang::StorageDuration getStorageDuration() const

Description

Retrieve the storage duration for the materialized temporary.

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

clang::Expr* getSubExpr() const

Description

Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.

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

bool isBoundToLvalueReference() const

Description

Determine whether this materialized temporary is bound to an lvalue reference; otherwise, it's bound to an rvalue reference.

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

bool isUsableInConstantExpressions(
    const clang::ASTContext& Context) const

Description

Determine whether this temporary object is usable in constant expressions, as specified in C++20 [expr.const]p4.

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

Parameters

const clang::ASTContext& Context

void setExtendingDecl(
    clang::ValueDecl* ExtendedBy,
    unsigned int ManglingNumber)

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

Parameters

clang::ValueDecl* ExtendedBy
unsigned int ManglingNumber