clang API Documentation

Classes | Public Member Functions | Static Public Member Functions | Friends
clang::MaterializeTemporaryExpr Class Reference

Represents a prvalue temporary that is written into memory so that a reference can bind to it. More...

#include <ExprCXX.h>

Inheritance diagram for clang::MaterializeTemporaryExpr:
Inheritance graph
[legend]
Collaboration diagram for clang::MaterializeTemporaryExpr:
Collaboration graph
[legend]

List of all members.

Classes

struct  ExtraState

Public Member Functions

 MaterializeTemporaryExpr (QualType T, Expr *Temporary, bool BoundToLvalueReference)
 MaterializeTemporaryExpr (EmptyShell Empty)
StmtgetTemporary () const
ExprGetTemporaryExpr () 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 ValueDeclgetExtendingDecl () 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

Detailed 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.,

 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.

Definition at line 3732 of file ExprCXX.h.


Constructor & Destructor Documentation

clang::MaterializeTemporaryExpr::MaterializeTemporaryExpr ( QualType  T,
Expr Temporary,
bool  BoundToLvalueReference 
) [inline]

Definition at line 3754 of file ExprCXX.h.

Definition at line 3763 of file ExprCXX.h.


Member Function Documentation

Reimplemented from clang::Stmt.

Definition at line 3818 of file ExprCXX.h.

References State.

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

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

Reimplemented from clang::Stmt.

Definition at line 3809 of file ExprCXX.h.

References clang::Stmt::getLocEnd(), and getTemporary().

Reimplemented from clang::Stmt.

Definition at line 3806 of file ExprCXX.h.

References clang::Stmt::getLocStart(), and getTemporary().

Definition at line 3796 of file ExprCXX.h.

References State.

Referenced by clang::CodeGen::CodeGenModule::GetAddrOfGlobalTemporary().

Definition at line 3766 of file ExprCXX.h.

References State.

Referenced by getLocEnd(), getLocStart(), and GetTemporaryExpr().

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.


Friends And Related Function Documentation

friend class ASTStmtReader [friend]

Reimplemented from clang::Stmt.

Definition at line 3747 of file ExprCXX.h.

friend class ASTStmtWriter [friend]

Reimplemented from clang::Stmt.

Definition at line 3748 of file ExprCXX.h.


The documentation for this class was generated from the following files: