]> granicus.if.org Git - clang/commitdiff
Add a CXXDestroyExpr. Add classof member functions to CXXTempVarDecl.
authorAnders Carlsson <andersca@mac.com>
Tue, 21 Apr 2009 02:22:11 +0000 (02:22 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 21 Apr 2009 02:22:11 +0000 (02:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69654 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclCXX.h
include/clang/AST/ExprCXX.h
include/clang/AST/StmtNodes.def
lib/AST/ExprCXX.cpp
lib/AST/StmtPrinter.cpp

index f7b5eb5fa1683521b99718bd0f72652b5fb7fdf9..5ac9be07f54a4cf5e30bbe137fd17eaa7fef188d 100644 (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
index fd7927a684a3f863d00c060f2d7d3b0313a47084..542a7dba4cac274b08addf1cf21dc0c84d34dcdf 100644 (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
index 211e6062866d315cc3ebaebebeb5e690759d7d4b..84ee6b3908cac8afa34b22648a967660c8b0d250 100644 (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)
index d73ea370cfb4af8105fe994171fe49aa2b82f741..0c9b6270a42f2714bae2a1e77f037dc13838f614 100644 (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();
+}
index 7f9c4cc8fba02067c40e545f8e6512b414dc52c9..888c15ad24a2eb1438fc631739bf960ec9d99a41 100644 (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");