forked from OSchip/llvm-project
parent
f337d8c515
commit
993a4b3080
|
@ -423,7 +423,38 @@ class CXXTemporary {
|
|||
public:
|
||||
static CXXTemporary *Create(ASTContext &C, CXXDestructorDecl *Destructor);
|
||||
};
|
||||
|
||||
/// CXXBindTemporaryExpr - Represents binding an expression to a temporary,
|
||||
/// so its destructor can be called later.
|
||||
class CXXBindTemporaryExpr : public Expr {
|
||||
CXXTemporary *Temp;
|
||||
|
||||
Stmt *SubExpr;
|
||||
|
||||
CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
|
||||
: Expr(CXXBindTemporaryExprClass,
|
||||
subexpr->getType()), Temp(temp), SubExpr(subexpr) { }
|
||||
|
||||
public:
|
||||
static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
|
||||
Expr* SubExpr);
|
||||
|
||||
const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
|
||||
Expr *getSubExpr() { return cast<Expr>(SubExpr); }
|
||||
|
||||
virtual SourceRange getSourceRange() const { return SourceRange(); }
|
||||
|
||||
// Implement isa/cast/dyncast/etc.
|
||||
static bool classof(const Stmt *T) {
|
||||
return T->getStmtClass() == CXXBindTemporaryExprClass;
|
||||
}
|
||||
static bool classof(const CXXBindTemporaryExpr *) { return true; }
|
||||
|
||||
// Iterators
|
||||
virtual child_iterator child_begin();
|
||||
virtual child_iterator child_end();
|
||||
};
|
||||
|
||||
/// CXXConstructExpr - Represents a call to a C++ constructor.
|
||||
class CXXConstructExpr : public Expr {
|
||||
VarDecl *VD;
|
||||
|
|
|
@ -124,6 +124,7 @@ EXPR(UnaryTypeTraitExpr , Expr)
|
|||
EXPR(QualifiedDeclRefExpr , DeclRefExpr)
|
||||
EXPR(UnresolvedDeclRefExpr , Expr)
|
||||
EXPR(CXXConstructExpr , Expr)
|
||||
EXPR(CXXBindTemporaryExpr , Expr)
|
||||
EXPR(CXXExprWithTemporaries , Expr)
|
||||
EXPR(CXXTemporaryObjectExpr , CXXConstructExpr)
|
||||
EXPR(CXXUnresolvedConstructExpr, Expr)
|
||||
|
|
|
@ -242,6 +242,15 @@ CXXTemporary *CXXTemporary::Create(ASTContext &C,
|
|||
return new CXXTemporary(Destructor);
|
||||
}
|
||||
|
||||
CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
|
||||
CXXTemporary *Temp,
|
||||
Expr* SubExpr) {
|
||||
assert(SubExpr->getType()->isRecordType() &&
|
||||
"Expression bound to a temporary must have record type!");
|
||||
|
||||
return new CXXBindTemporaryExpr(Temp, SubExpr);
|
||||
}
|
||||
|
||||
CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C, VarDecl *vd,
|
||||
CXXConstructorDecl *Cons,
|
||||
QualType writtenTy,
|
||||
|
@ -303,6 +312,15 @@ CXXExprWithTemporaries::~CXXExprWithTemporaries() {
|
|||
delete[] Decls;
|
||||
}
|
||||
|
||||
// CXXBindTemporaryExpr
|
||||
Stmt::child_iterator CXXBindTemporaryExpr::child_begin() {
|
||||
return &SubExpr;
|
||||
}
|
||||
|
||||
Stmt::child_iterator CXXBindTemporaryExpr::child_end() {
|
||||
return &SubExpr + 1;
|
||||
}
|
||||
|
||||
// CXXConstructExpr
|
||||
Stmt::child_iterator CXXConstructExpr::child_begin() {
|
||||
return &Args[0];
|
||||
|
|
|
@ -988,6 +988,10 @@ void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
|
|||
OS << ")";
|
||||
}
|
||||
|
||||
void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
|
||||
PrintExpr(Node->getSubExpr());
|
||||
}
|
||||
|
||||
void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
|
||||
OS << Node->getType().getAsString();
|
||||
OS << "(";
|
||||
|
|
|
@ -975,6 +975,16 @@ TemplateExprInstantiator::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
|
|||
return SemaRef.ExprError();
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitCXXBindTemporaryExpr(
|
||||
CXXBindTemporaryExpr *E) {
|
||||
OwningExprResult SubExpr = Visit(E->getSubExpr());
|
||||
if (SubExpr.isInvalid())
|
||||
return SemaRef.ExprError();
|
||||
|
||||
return move(SubExpr);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitCXXConstructExpr(CXXConstructExpr *E) {
|
||||
assert(!cast<CXXRecordDecl>(E->getConstructor()->getDeclContext())
|
||||
|
|
Loading…
Reference in New Issue