Add a CXXDestroyExpr. Add classof member functions to CXXTempVarDecl.

llvm-svn: 69654
This commit is contained in:
Anders Carlsson 2009-04-21 02:22:11 +00:00
parent f09cb95236
commit 6f2878360c
5 changed files with 48 additions and 0 deletions

View File

@ -1064,6 +1064,11 @@ protected:
public:
static CXXTempVarDecl *Create(ASTContext &C, DeclContext *DC,
QualType T);
static bool classof(const Decl *D) {
return D->getKind() == Decl::CXXTempVar;
}
static bool classof(CXXTempVarDecl *D) { return true; }
};
/// Insertion operator for diagnostics. This allows sending AccessSpecifier's

View File

@ -949,6 +949,30 @@ public:
virtual StmtIterator child_end();
};
class CXXDestroyExpr : public Expr {
VarDecl *VD;
protected:
CXXDestroyExpr(VarDecl* vd, QualType T)
: Expr(CXXDestroyExprClass, T, false, vd->getType()->isDependentType()),
VD(vd) { }
public:
static CXXDestroyExpr *Create(ASTContext &C, VarDecl *vd);
virtual SourceRange getSourceRange() const { return SourceRange(); }
// Implement isa/cast/dyncast/etc.
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXDestroyExprClass;
}
static bool classof(const CXXDestroyExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
} // end namespace clang
#endif

View File

@ -119,6 +119,7 @@ STMT(UnresolvedFunctionNameExpr , Expr)
STMT(UnaryTypeTraitExpr , Expr)
STMT(QualifiedDeclRefExpr , DeclRefExpr)
STMT(UnresolvedDeclRefExpr , Expr)
STMT(CXXDestroyExpr , Expr)
// Obj-C Expressions.
STMT(ObjCStringLiteral , Expr)

View File

@ -253,3 +253,17 @@ CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(CXXConstructorDecl *Cons,
CXXTemporaryObjectExpr::~CXXTemporaryObjectExpr() {
delete [] Args;
}
CXXDestroyExpr *CXXDestroyExpr::Create(ASTContext &C, VarDecl *vd) {
assert(vd->getKind() == Decl::CXXTempVar || vd->getKind() == Decl::Var &&
"Can only create a destroy expr with a temp var decl or a var decl!");
return new (C) CXXDestroyExpr(vd, C.VoidTy);
}
Stmt::child_iterator CXXDestroyExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator CXXDestroyExpr::child_end() {
return child_iterator();
}

View File

@ -1097,6 +1097,10 @@ void StmtPrinter::VisitUnresolvedFunctionNameExpr(UnresolvedFunctionNameExpr *E)
OS << E->getName().getAsString();
}
void StmtPrinter::VisitCXXDestroyExpr(CXXDestroyExpr *E) {
// Nothing to print.
}
static const char *getTypeTraitName(UnaryTypeTrait UTT) {
switch (UTT) {
default: assert(false && "Unknown type trait");