[cfe-commits] r69654 - in /cfe/trunk: include/clang/AST/DeclCXX.h include/clang/AST/ExprCXX.h include/clang/AST/StmtNodes.def lib/AST/ExprCXX.cpp lib/AST/StmtPrinter.cpp

Anders Carlsson andersca at mac.com
Mon Apr 20 19:22:11 PDT 2009


Author: andersca
Date: Mon Apr 20 21:22:11 2009
New Revision: 69654

URL: http://llvm.org/viewvc/llvm-project?rev=69654&view=rev
Log:
Add a CXXDestroyExpr. Add classof member functions to CXXTempVarDecl.

Modified:
    cfe/trunk/include/clang/AST/DeclCXX.h
    cfe/trunk/include/clang/AST/ExprCXX.h
    cfe/trunk/include/clang/AST/StmtNodes.def
    cfe/trunk/lib/AST/ExprCXX.cpp
    cfe/trunk/lib/AST/StmtPrinter.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=69654&r1=69653&r2=69654&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Apr 20 21:22:11 2009
@@ -1064,6 +1064,11 @@
 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

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=69654&r1=69653&r2=69654&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Apr 20 21:22:11 2009
@@ -949,6 +949,30 @@
   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

Modified: cfe/trunk/include/clang/AST/StmtNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtNodes.def?rev=69654&r1=69653&r2=69654&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/StmtNodes.def (original)
+++ cfe/trunk/include/clang/AST/StmtNodes.def Mon Apr 20 21:22:11 2009
@@ -119,6 +119,7 @@
 STMT(UnaryTypeTraitExpr     , Expr)
 STMT(QualifiedDeclRefExpr   , DeclRefExpr)
 STMT(UnresolvedDeclRefExpr  , Expr)
+STMT(CXXDestroyExpr         , Expr)
 
 // Obj-C Expressions.
 STMT(ObjCStringLiteral    , Expr)

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=69654&r1=69653&r2=69654&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Mon Apr 20 21:22:11 2009
@@ -253,3 +253,17 @@
 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();
+}

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=69654&r1=69653&r2=69654&view=diff

==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Apr 20 21:22:11 2009
@@ -1097,6 +1097,10 @@
   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");





More information about the cfe-commits mailing list