clang API Documentation
Represents a prvalue temporary that is written into memory so that a reference can bind to it. More...
#include <ExprCXX.h>
Classes | |
struct | ExtraState |
Public Member Functions | |
MaterializeTemporaryExpr (QualType T, Expr *Temporary, bool BoundToLvalueReference) | |
MaterializeTemporaryExpr (EmptyShell Empty) | |
Stmt * | getTemporary () const |
Expr * | GetTemporaryExpr () const |
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue. | |
StorageDuration | getStorageDuration () const |
Retrieve the storage duration for the materialized temporary. | |
const ValueDecl * | getExtendingDecl () const |
Get the declaration which triggered the lifetime-extension of this temporary, if any. | |
void | setExtendingDecl (const ValueDecl *ExtendedBy, unsigned ManglingNumber) |
unsigned | getManglingNumber () const |
bool | isBoundToLvalueReference () const |
Determine whether this materialized temporary is bound to an lvalue reference; otherwise, it's bound to an rvalue reference. | |
SourceLocation | getLocStart () const LLVM_READONLY |
SourceLocation | getLocEnd () const LLVM_READONLY |
child_range | children () |
Static Public Member Functions | |
static bool | classof (const Stmt *T) |
Friends | |
class | ASTStmtReader |
class | ASTStmtWriter |
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.,
const int &r = 1.0;
Here, 1.0 is implicitly converted to an int
. That resulting int
is then materialized via a MaterializeTemporaryExpr
, and the reference binds to the temporary. 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.
clang::MaterializeTemporaryExpr::MaterializeTemporaryExpr | ( | QualType | T, |
Expr * | Temporary, | ||
bool | BoundToLvalueReference | ||
) | [inline] |
clang::MaterializeTemporaryExpr::MaterializeTemporaryExpr | ( | EmptyShell | Empty | ) | [inline] |
child_range clang::MaterializeTemporaryExpr::children | ( | ) | [inline] |
static bool clang::MaterializeTemporaryExpr::classof | ( | const Stmt * | T | ) | [inline, static] |
Reimplemented from clang::Expr.
Definition at line 3813 of file ExprCXX.h.
References clang::Stmt::getStmtClass().
const ValueDecl* clang::MaterializeTemporaryExpr::getExtendingDecl | ( | ) | const [inline] |
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition at line 3789 of file ExprCXX.h.
References State.
Referenced by clang::CodeGen::CodeGenFunction::EmitMaterializeTemporaryExpr(), clang::CodeGen::CodeGenModule::GetAddrOfGlobalTemporary(), getStorageDuration(), and pushTemporaryCleanup().
SourceLocation clang::MaterializeTemporaryExpr::getLocEnd | ( | ) | const [inline] |
Reimplemented from clang::Stmt.
Definition at line 3809 of file ExprCXX.h.
References clang::Stmt::getLocEnd(), and getTemporary().
SourceLocation clang::MaterializeTemporaryExpr::getLocStart | ( | ) | const [inline] |
Reimplemented from clang::Stmt.
Definition at line 3806 of file ExprCXX.h.
References clang::Stmt::getLocStart(), and getTemporary().
unsigned clang::MaterializeTemporaryExpr::getManglingNumber | ( | ) | const [inline] |
Definition at line 3796 of file ExprCXX.h.
References State.
Referenced by clang::CodeGen::CodeGenModule::GetAddrOfGlobalTemporary().
StorageDuration clang::MaterializeTemporaryExpr::getStorageDuration | ( | ) | const [inline] |
Retrieve the storage duration for the materialized temporary.
Definition at line 3776 of file ExprCXX.h.
References getExtendingDecl(), clang::SD_Automatic, and clang::SD_FullExpression.
Referenced by createReferenceTemporary(), clang::CodeGen::CodeGenModule::GetAddrOfGlobalTemporary(), clang::ASTContext::getMaterializedTemporaryValue(), clang::InitializationSequence::Perform(), and pushTemporaryCleanup().
Stmt* clang::MaterializeTemporaryExpr::getTemporary | ( | ) | const [inline] |
Definition at line 3766 of file ExprCXX.h.
References State.
Referenced by getLocEnd(), getLocStart(), and GetTemporaryExpr().
Expr* clang::MaterializeTemporaryExpr::GetTemporaryExpr | ( | ) | const [inline] |
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
Definition at line 3773 of file ExprCXX.h.
References getTemporary().
Referenced by clang::ento::ExprEngine::CreateCXXTemporaryObject(), clang::CodeGen::CodeGenFunction::EmitMaterializeTemporaryExpr(), clang::CodeGen::CodeGenModule::GetAddrOfGlobalTemporary(), and clang::consumed::ConsumedStmtVisitor::VisitMaterializeTemporaryExpr().
bool clang::MaterializeTemporaryExpr::isBoundToLvalueReference | ( | ) | const [inline] |
Determine whether this materialized temporary is bound to an lvalue reference; otherwise, it's bound to an rvalue reference.
Definition at line 3802 of file ExprCXX.h.
References clang::Expr::getValueKind(), and clang::VK_LValue.
void MaterializeTemporaryExpr::setExtendingDecl | ( | const ValueDecl * | ExtendedBy, |
unsigned | ManglingNumber | ||
) |
Definition at line 1473 of file ExprCXX.cpp.
References clang::Decl::getASTContext(), and State.
friend class ASTStmtReader [friend] |
Reimplemented from clang::Stmt.
friend class ASTStmtWriter [friend] |
Reimplemented from clang::Stmt.