[cfe-commits] r109377 - in /cfe/trunk: include/clang/AST/ lib/AST/ lib/CodeGen/ lib/Sema/

Douglas Gregor dgregor at apple.com
Sun Jul 25 11:17:45 PDT 2010


Author: dgregor
Date: Sun Jul 25 13:17:45 2010
New Revision: 109377

URL: http://llvm.org/viewvc/llvm-project?rev=109377&view=rev
Log:
Remove the vast majority of the Destroy methods from the AST library,
since we aren't going to be calling them ever.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/include/clang/AST/DeclCXX.h
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/include/clang/AST/DeclTemplate.h
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/include/clang/AST/ExprCXX.h
    cfe/trunk/include/clang/AST/FullExpr.h
    cfe/trunk/include/clang/AST/Stmt.h
    cfe/trunk/include/clang/AST/StmtCXX.h
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/AST/DeclTemplate.cpp
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/AST/ExprCXX.cpp
    cfe/trunk/lib/AST/FullExpr.cpp
    cfe/trunk/lib/AST/Stmt.cpp
    cfe/trunk/lib/AST/Type.cpp
    cfe/trunk/lib/CodeGen/CGVTables.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/SemaAttr.cpp
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sun Jul 25 13:17:45 2010
@@ -264,8 +264,6 @@
   static NamespaceDecl *Create(ASTContext &C, DeclContext *DC,
                                SourceLocation L, IdentifierInfo *Id);
 
-  virtual void Destroy(ASTContext& C);
-
   // \brief Returns true if this is an anonymous namespace declaration.
   //
   // For example:
@@ -392,8 +390,6 @@
                                      unsigned NumTPLists,
                                      TemplateParameterList **TPLists);
   
-  void Destroy(ASTContext &Context);
-  
 private:
   // Copy constructor and copy assignment are disabled.
   QualifierInfo(const QualifierInfo&);
@@ -422,7 +418,6 @@
 
 public:
   virtual ~DeclaratorDecl();
-  virtual void Destroy(ASTContext &C);
 
   TypeSourceInfo *getTypeSourceInfo() const {
     return hasExtInfo()
@@ -609,7 +604,6 @@
                          QualType T, TypeSourceInfo *TInfo, StorageClass S,
                          StorageClass SCAsWritten);
 
-  virtual void Destroy(ASTContext& C);
   virtual ~VarDecl();
 
   virtual SourceLocation getInnerLocStart() const;
@@ -1194,7 +1188,6 @@
       EndRangeLoc(L), TemplateOrSpecialization() {}
 
   virtual ~FunctionDecl() {}
-  virtual void Destroy(ASTContext& C);
 
   typedef Redeclarable<FunctionDecl> redeclarable_base;
   virtual FunctionDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
@@ -1713,8 +1706,6 @@
                                   QualType T, Expr *E,
                                   const llvm::APSInt &V);
 
-  virtual void Destroy(ASTContext& C);
-
   const Expr *getInitExpr() const { return (const Expr*) Init; }
   Expr *getInitExpr() { return (Expr*) Init; }
   const llvm::APSInt &getInitVal() const { return Val; }
@@ -1881,8 +1872,6 @@
   virtual TagDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
 
 public:
-  void Destroy(ASTContext &C);
-
   typedef redeclarable_base::redecl_iterator redecl_iterator;
   redecl_iterator redecls_begin() const {
     return redeclarable_base::redecls_begin();
@@ -2060,8 +2049,6 @@
                           SourceLocation TKL, EnumDecl *PrevDecl);
   static EnumDecl *Create(ASTContext &C, EmptyShell Empty);
 
-  virtual void Destroy(ASTContext& C);
-
   /// completeDefinition - When created, the EnumDecl corresponds to a
   /// forward-declared enum. This method is used to mark the
   /// declaration as being defined; it's enumerators have already been
@@ -2185,8 +2172,6 @@
     return cast_or_null<RecordDecl>(TagDecl::getPreviousDeclaration());
   }
 
-  virtual void Destroy(ASTContext& C);
-
   bool hasFlexibleArrayMember() const { return HasFlexibleArrayMember; }
   void setHasFlexibleArrayMember(bool V) { HasFlexibleArrayMember = V; }
 
@@ -2310,7 +2295,6 @@
       SignatureAsWritten(0) {}
 
   virtual ~BlockDecl();
-  virtual void Destroy(ASTContext& C);
 
 public:
   static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L);

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Sun Jul 25 13:17:45 2010
@@ -572,9 +572,6 @@
   static DeclContext *castToDeclContext(const Decl *);
   static Decl *castFromDeclContext(const DeclContext *);
 
-  /// Destroy - Call destructors and release memory.
-  virtual void Destroy(ASTContext& C);
-
   void print(llvm::raw_ostream &Out, unsigned Indentation = 0) const;
   void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy,
              unsigned Indentation = 0) const;
@@ -654,8 +651,6 @@
        ExternalVisibleStorage(false), LookupPtr(0), FirstDecl(0),
        LastDecl(0) { }
 
-  void DestroyDecls(ASTContext &C);
-
 public:
   ~DeclContext();
 

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Sun Jul 25 13:17:45 2010
@@ -449,8 +449,6 @@
                                bool DelayTypeCreation = false);
   static CXXRecordDecl *Create(ASTContext &C, EmptyShell Empty);
 
-  virtual void Destroy(ASTContext& C);
-
   bool isDynamicClass() const {
     return data().Polymorphic || data().NumVBases != 0;
   }
@@ -1249,9 +1247,6 @@
                                             VarDecl **Indices,
                                             unsigned NumIndices);
   
-  /// \brief Destroy the base or member initializer.
-  void Destroy(ASTContext &Context);
-
   /// isBaseInitializer - Returns true when this initializer is
   /// initializing a base class.
   bool isBaseInitializer() const { return BaseOrMember.is<TypeSourceInfo*>(); }
@@ -1404,7 +1399,6 @@
       BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) {
     setImplicit(isImplicitlyDeclared);
   }
-  virtual void Destroy(ASTContext& C);
 
 public:
   static CXXConstructorDecl *Create(ASTContext &C, EmptyShell Empty);
@@ -2244,7 +2238,6 @@
   const StringLiteral *getMessage() const { return Message; }
 
   virtual ~StaticAssertDecl();
-  virtual void Destroy(ASTContext& C);
 
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classof(StaticAssertDecl *D) { return true; }

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sun Jul 25 13:17:45 2010
@@ -42,11 +42,8 @@
 public:
   ObjCListBase() : List(0), NumElts(0) {}
   ~ObjCListBase() {
-    assert(List == 0 && "Destroy should have been called before dtor");
   }
 
-  void Destroy(ASTContext &Ctx);
-
   unsigned size() const { return NumElts; }
   bool empty() const { return NumElts == 0; }
 
@@ -92,7 +89,6 @@
 
   void set(ObjCProtocolDecl* const* InList, unsigned Elts, 
            const SourceLocation *Locs, ASTContext &Ctx);
-  void Destroy(ASTContext &Ctx);
 };
 
 
@@ -195,10 +191,6 @@
   virtual ObjCMethodDecl *getNextRedeclaration();
 
 public:
-
-  /// Destroy - Call destructors and release memory.
-  virtual void Destroy(ASTContext& C);
-
   static ObjCMethodDecl *Create(ASTContext &C,
                                 SourceLocation beginLoc,
                                 SourceLocation endLoc, Selector SelInfo,
@@ -494,10 +486,6 @@
   virtual ~ObjCInterfaceDecl() {}
 
 public:
-
-  /// Destroy - Call destructors and release memory.
-  virtual void Destroy(ASTContext& C);
-
   static ObjCInterfaceDecl *Create(ASTContext &C, DeclContext *DC,
                                    SourceLocation atLoc,
                                    IdentifierInfo *Id,
@@ -715,8 +703,6 @@
                                      IdentifierInfo *Id, QualType T,
                                      Expr *BW);
 
-  virtual void Destroy(ASTContext& C);
-
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classof(const ObjCAtDefsFieldDecl *D) { return true; }
@@ -766,9 +752,6 @@
   static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC,
                                   SourceLocation L, IdentifierInfo *Id);
 
-  /// Destroy - Call destructors and release memory.
-  virtual void Destroy(ASTContext& C);
-
   const ObjCProtocolList &getReferencedProtocols() const {
     return ReferencedProtocols;
   }
@@ -839,10 +822,6 @@
                 unsigned nElts, ASTContext &C);
   virtual ~ObjCClassDecl() {}
 public:
-
-  /// Destroy - Call destructors and release memory.
-  virtual void Destroy(ASTContext& C);
-
   static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
                                ObjCInterfaceDecl *const *Elts = 0,
                                const SourceLocation *Locs = 0,
@@ -889,9 +868,6 @@
     return Create(C, DC, L, 0, 0, 0);
   }
 
-  /// Destroy - Call destructors and release memory.
-  virtual void Destroy(ASTContext& C);
-
   typedef ObjCProtocolList::iterator protocol_iterator;
   protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
   protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Sun Jul 25 13:17:45 2010
@@ -193,11 +193,6 @@
 
   TemplateArgumentList() : NumFlatArguments(0), NumStructuredArguments(0) { }
 
-  /// Used to release the memory associated with a TemplateArgumentList
-  ///  object.  FIXME: This is currently not called anywhere, but the
-  ///  memory will still be freed when using a BumpPtrAllocator.
-  void Destroy(ASTContext &C);
-
   ~TemplateArgumentList();
   
   /// \brief Copies the template arguments into a locally new[]'d array.
@@ -542,8 +537,6 @@
       CommonOrPrev((Common*)0) { }
 
 public:
-  void Destroy(ASTContext &C);
-
   /// Get the underlying function declaration of the template.
   FunctionDecl *getTemplatedDecl() const {
     return static_cast<FunctionDecl*>(TemplatedDecl);
@@ -1004,8 +997,6 @@
   static ClassTemplateSpecializationDecl *
   Create(ASTContext &Context, EmptyShell Empty);
 
-  virtual void Destroy(ASTContext& C);
-
   virtual void getNameForDiagnostic(std::string &S,
                                     const PrintingPolicy &Policy,
                                     bool Qualified) const;
@@ -1609,8 +1600,6 @@
   static bool classof(const ClassTemplateDecl *D) { return true; }
   static bool classofKind(Kind K) { return K == ClassTemplate; }
 
-  virtual void Destroy(ASTContext& C);
-
   friend class PCHDeclReader;
   friend class PCHDeclWriter;
 };

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Jul 25 13:17:45 2010
@@ -888,9 +888,6 @@
 
   StringLiteral(QualType Ty) : Expr(StringLiteralClass, Ty, false, false) {}
 
-protected:
-  virtual void DoDestroy(ASTContext &C);
-
 public:
   /// This is the "fully general" constructor that allows representation of
   /// strings formed from multiple concatenated tokens.
@@ -1309,9 +1306,6 @@
   } Argument;
   SourceLocation OpLoc, RParenLoc;
 
-protected:
-  virtual void DoDestroy(ASTContext& C);
-
 public:
   SizeOfAlignOfExpr(bool issizeof, TypeSourceInfo *TInfo,
                     QualType resultType, SourceLocation op,
@@ -1484,8 +1478,6 @@
   CallExpr(ASTContext& C, StmtClass SC, Expr *fn, Expr **args, unsigned numargs,
            QualType t, SourceLocation rparenloc);
 
-  virtual void DoDestroy(ASTContext& C);
-
 public:
   CallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, QualType t,
            SourceLocation rparenloc);
@@ -2004,8 +1996,6 @@
   CastExpr(StmtClass SC, EmptyShell Empty)
     : Expr(SC, Empty) { }
 
-  virtual void DoDestroy(ASTContext &C);
-
 public:
   CastKind getCastKind() const { return Kind; }
   void setCastKind(CastKind K) { Kind = K; }
@@ -2561,9 +2551,6 @@
   Stmt **SubExprs;
   unsigned NumExprs;
 
-protected:
-  virtual void DoDestroy(ASTContext &C);
-
 public:
   // FIXME: Can a shufflevector be value-dependent?  Does type-dependence need
   // to be computed differently?
@@ -2975,11 +2962,6 @@
     : Expr(DesignatedInitExprClass, EmptyShell()),
       NumDesignators(0), Designators(0), NumSubExprs(NumSubExprs) { }
 
-protected:
-  virtual void DoDestroy(ASTContext &C);
-
-  void DestroyDesignators(ASTContext &C);
-  
 public:
   /// A field designator, e.g., ".x".
   struct FieldDesignator {
@@ -3247,9 +3229,6 @@
   unsigned NumExprs;
   SourceLocation LParenLoc, RParenLoc;
 
-protected:
-  virtual void DoDestroy(ASTContext& C);
-
 public:
   ParenListExpr(ASTContext& C, SourceLocation lparenloc, Expr **exprs,
                 unsigned numexprs, SourceLocation rparenloc);

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Sun Jul 25 13:17:45 2010
@@ -479,9 +479,6 @@
     *reinterpret_cast<Expr **>(this + 1) = SubExpr;
   }
   
-protected:
-  virtual void DoDestroy(ASTContext &C);
-  
 public:
   CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
 
@@ -552,8 +549,6 @@
   static CXXTemporary *Create(ASTContext &C,
                               const CXXDestructorDecl *Destructor);
 
-  void Destroy(ASTContext &Ctx);
-
   const CXXDestructorDecl *getDestructor() const { return Destructor; }
 };
 
@@ -581,9 +576,6 @@
      Temp(temp), SubExpr(subexpr) { }
   ~CXXBindTemporaryExpr() { }
 
-protected:
-  virtual void DoDestroy(ASTContext &C);
-
 public:
   CXXBindTemporaryExpr(EmptyShell Empty)
     : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {}
@@ -641,9 +633,6 @@
     RequiresTemporaryCopy(RequiresTemporaryCopy) { }
   ~CXXBindReferenceExpr() { }
 
-protected:
-  virtual void DoDestroy(ASTContext &C);
-
 public:
   static CXXBindReferenceExpr *Create(ASTContext &C, Expr *SubExpr,
                                       bool ExtendsLifetime, 
@@ -714,8 +703,6 @@
     : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0),
       ConstructKind(0), Args(0), NumArgs(0) { }
 
-  virtual void DoDestroy(ASTContext &C);
-
 public:
   /// \brief Construct an empty C++ construction expression.
   explicit CXXConstructExpr(EmptyShell Empty)
@@ -967,8 +954,6 @@
   void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs,
                          unsigned numConsArgs);
   
-  virtual void DoDestroy(ASTContext &C);
-
   QualType getAllocatedType() const {
     assert(getType()->isPointerType());
     return getType()->getAs<PointerType>()->getPointeeType();
@@ -1779,9 +1764,6 @@
                          unsigned NumTemps);
   ~CXXExprWithTemporaries();
 
-protected:
-  virtual void DoDestroy(ASTContext &C);
-
 public:
   CXXExprWithTemporaries(EmptyShell Empty)
     : Expr(CXXExprWithTemporariesClass, Empty),

Modified: cfe/trunk/include/clang/AST/FullExpr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/FullExpr.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/FullExpr.h (original)
+++ cfe/trunk/include/clang/AST/FullExpr.h Sun Jul 25 13:17:45 2010
@@ -47,7 +47,6 @@
 public:
   static FullExpr Create(ASTContext &Context, Expr *SubExpr, 
                          CXXTemporary **Temps, unsigned NumTemps);
-  void Destroy(ASTContext &Context);
   
   Expr *getExpr() {
     if (Expr *E = SubExpr.dyn_cast<Expr *>())

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sun Jul 25 13:17:45 2010
@@ -151,22 +151,11 @@
   struct EmptyShell { };
 
 protected:
-  /// DestroyChildren - Invoked by destructors of subclasses of Stmt to
-  ///  recursively release child AST nodes.
-  void DestroyChildren(ASTContext& Ctx);
-
   /// \brief Construct an empty statement.
   explicit Stmt(StmtClass SC, EmptyShell) : sClass(SC), RefCount(1) {
     if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
   }
 
-  /// \brief Virtual method that performs the actual destruction of
-  /// this statement.
-  ///
-  /// Subclasses should override this method (not Destroy()) to
-  /// provide class-specific destruction.
-  virtual void DoDestroy(ASTContext &Ctx);
-
 public:
   Stmt(StmtClass SC) : sClass(SC), RefCount(1) {
     if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
@@ -181,13 +170,6 @@
   }
 #endif
 
-  /// \brief Destroy the current statement and its children.
-  void Destroy(ASTContext &Ctx) {
-    assert(RefCount >= 1);
-    if (--RefCount == 0)
-      DoDestroy(Ctx);
-  }
-
   /// \brief Increases the reference count for this statement.
   ///
   /// Invoke the Retain() operation when this statement or expression
@@ -295,9 +277,6 @@
   DeclGroupRef DG;
   SourceLocation StartLoc, EndLoc;
 
-protected:
-  virtual void DoDestroy(ASTContext &Ctx);
-
 public:
   DeclStmt(DeclGroupRef dg, SourceLocation startLoc,
            SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg),
@@ -671,9 +650,6 @@
   // over the initialization expression referenced by the condition variable.
   virtual child_iterator child_begin();
   virtual child_iterator child_end();
-
-protected:
-  virtual void DoDestroy(ASTContext &Ctx);
 };
 
 /// SwitchStmt - This represents a 'switch' stmt.
@@ -685,9 +661,6 @@
   SwitchCase *FirstCase;
   SourceLocation SwitchLoc;
 
-protected:
-  virtual void DoDestroy(ASTContext &Ctx);
-
 public:
   SwitchStmt(ASTContext &C, VarDecl *Var, Expr *cond);
 
@@ -794,9 +767,6 @@
   // Iterators
   virtual child_iterator child_begin();
   virtual child_iterator child_end();
-  
-protected:
-  virtual void DoDestroy(ASTContext &Ctx);
 };
 
 /// DoStmt - This represents a 'do/while' stmt.
@@ -910,9 +880,6 @@
   // Iterators
   virtual child_iterator child_begin();
   virtual child_iterator child_end();
-  
-protected:
-  virtual void DoDestroy(ASTContext &Ctx);
 };
 
 /// GotoStmt - This represents a direct goto.
@@ -1113,9 +1080,6 @@
   StringLiteral **Constraints;
   Stmt **Exprs;
   StringLiteral **Clobbers;
-
-protected:
-  virtual void DoDestroy(ASTContext &Ctx);
   
 public:
   AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, bool isvolatile, 

Modified: cfe/trunk/include/clang/AST/StmtCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtCXX.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtCXX.h (original)
+++ cfe/trunk/include/clang/AST/StmtCXX.h Sun Jul 25 13:17:45 2010
@@ -29,9 +29,6 @@
   /// The handler block.
   Stmt *HandlerBlock;
 
-protected:
-  virtual void DoDestroy(ASTContext& Ctx);
-
 public:
   CXXCatchStmt(SourceLocation catchLoc, VarDecl *exDecl, Stmt *handlerBlock)
   : Stmt(CXXCatchStmtClass), CatchLoc(catchLoc), ExceptionDecl(exDecl),

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sun Jul 25 13:17:45 2010
@@ -808,7 +808,6 @@
       TC(tc), Dependent(dependent), LinkageKnown(false), 
       CachedLinkage(NoLinkage), FromPCH(false) {}
   virtual ~Type() {}
-  virtual void Destroy(ASTContext& C);
   friend class ASTContext;
 
 public:
@@ -1545,7 +1544,6 @@
     : ArrayType(VariableArray, et, can, sm, tq),
       SizeExpr((Stmt*) e), Brackets(brackets) {}
   friend class ASTContext;  // ASTContext creates these.
-  virtual void Destroy(ASTContext& C);
 
 public:
   Expr *getSizeExpr() const {
@@ -1604,7 +1602,6 @@
     : ArrayType(DependentSizedArray, et, can, sm, tq),
       Context(Context), SizeExpr((Stmt*) e), Brackets(brackets) {}
   friend class ASTContext;  // ASTContext creates these.
-  virtual void Destroy(ASTContext& C);
 
 public:
   Expr *getSizeExpr() const {
@@ -1658,7 +1655,6 @@
       Context(Context), SizeExpr(SizeExpr), ElementType(ElementType),
       loc(loc) {}
   friend class ASTContext;
-  virtual void Destroy(ASTContext& C);
 
 public:
   Expr *getSizeExpr() const { return SizeExpr; }
@@ -2480,8 +2476,6 @@
                              const TemplateArgument *Args,
                              unsigned NumArgs, QualType Canon);
 
-  virtual void Destroy(ASTContext& C);
-
   friend class ASTContext;  // ASTContext creates these
 
 public:
@@ -2848,8 +2842,6 @@
                                       const TemplateArgument *Args,
                                       QualType Canon);
 
-  virtual void Destroy(ASTContext& C);
-
   friend class ASTContext;  // ASTContext creates these
 
 public:
@@ -3026,8 +3018,6 @@
     : ObjCObjectType(Canonical, Base, Protocols, NumProtocols) {}
 
 public:
-  void Destroy(ASTContext& C); // key function
-
   void Profile(llvm::FoldingSetNodeID &ID);
   static void Profile(llvm::FoldingSetNodeID &ID,
                       QualType Base,
@@ -3061,8 +3051,6 @@
       Decl(const_cast<ObjCInterfaceDecl*>(D)) {}
   friend class ASTContext;  // ASTContext creates these.
 public:
-  void Destroy(ASTContext& C); // key function
-
   /// getDecl - Get the declaration of this interface.
   ObjCInterfaceDecl *getDecl() const { return Decl; }
 
@@ -3115,8 +3103,6 @@
   virtual Linkage getLinkageImpl() const;
   
 public:
-  void Destroy(ASTContext& C);
-
   /// getPointeeType - Gets the type pointed to by this ObjC pointer.
   /// The result will always be an ObjCObjectType or sugar thereof.
   QualType getPointeeType() const { return PointeeType; }

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Sun Jul 25 13:17:45 2010
@@ -532,11 +532,6 @@
 }
 
 DeclaratorDecl::~DeclaratorDecl() {}
-void DeclaratorDecl::Destroy(ASTContext &C) {
-  if (hasExtInfo())
-    C.Deallocate(getExtInfo());
-  ValueDecl::Destroy(C);
-}
 
 SourceLocation DeclaratorDecl::getTypeSpecStartLoc() const {
   TypeSourceInfo *TSI = getTypeSourceInfo();
@@ -602,12 +597,6 @@
   }
 }
 
-void QualifierInfo::Destroy(ASTContext &Context) {
-  // FIXME: Deallocate template parameter lists themselves!
-  if (TemplParamLists)
-    Context.Deallocate(TemplParamLists);
-}
-
 //===----------------------------------------------------------------------===//
 // VarDecl Implementation
 //===----------------------------------------------------------------------===//
@@ -632,19 +621,6 @@
   return new (C) VarDecl(Var, DC, L, Id, T, TInfo, S, SCAsWritten);
 }
 
-void VarDecl::Destroy(ASTContext& C) {
-  Expr *Init = getInit();
-  if (Init) {
-    Init->Destroy(C);
-    if (EvaluatedStmt *Eval = this->Init.dyn_cast<EvaluatedStmt *>()) {
-      Eval->~EvaluatedStmt();
-      C.Deallocate(Eval);
-    }
-  }
-  this->~VarDecl();
-  DeclaratorDecl::Destroy(C);
-}
-
 VarDecl::~VarDecl() {
 }
 
@@ -912,28 +888,6 @@
 // FunctionDecl Implementation
 //===----------------------------------------------------------------------===//
 
-void FunctionDecl::Destroy(ASTContext& C) {
-  if (Body && Body.isOffset())
-    Body.get(C.getExternalSource())->Destroy(C);
-
-  for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
-    (*I)->Destroy(C);
-
-  FunctionTemplateSpecializationInfo *FTSInfo
-    = TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
-  if (FTSInfo)
-    C.Deallocate(FTSInfo);
-  
-  MemberSpecializationInfo *MSInfo
-    = TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo*>();
-  if (MSInfo)
-    C.Deallocate(MSInfo);
-  
-  C.Deallocate(ParamInfo);
-
-  DeclaratorDecl::Destroy(C);
-}
-
 void FunctionDecl::getNameForDiagnostic(std::string &S,
                                         const PrintingPolicy &Policy,
                                         bool Qualified) const {
@@ -1565,12 +1519,6 @@
 // TagDecl Implementation
 //===----------------------------------------------------------------------===//
 
-void TagDecl::Destroy(ASTContext &C) {
-  if (hasExtInfo())
-    C.Deallocate(getExtInfo());
-  TypeDecl::Destroy(C);
-}
-
 SourceLocation TagDecl::getOuterLocStart() const {
   return getTemplateOrInnerLocStart(this);
 }
@@ -1676,10 +1624,6 @@
   return new (C) EnumDecl(0, SourceLocation(), 0, 0, SourceLocation());
 }
 
-void EnumDecl::Destroy(ASTContext& C) {
-  TagDecl::Destroy(C);
-}
-
 void EnumDecl::completeDefinition(QualType NewType,
                                   QualType NewPromotionType,
                                   unsigned NumPositiveBits,
@@ -1723,10 +1667,6 @@
 RecordDecl::~RecordDecl() {
 }
 
-void RecordDecl::Destroy(ASTContext& C) {
-  TagDecl::Destroy(C);
-}
-
 bool RecordDecl::isInjectedClassName() const {
   return isImplicit() && getDeclName() && getDeclContext()->isRecord() &&
     cast<RecordDecl>(getDeclContext())->getDeclName() == getDeclName();
@@ -1757,17 +1697,6 @@
 BlockDecl::~BlockDecl() {
 }
 
-void BlockDecl::Destroy(ASTContext& C) {
-  if (Body)
-    Body->Destroy(C);
-
-  for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
-    (*I)->Destroy(C);
-
-  C.Deallocate(ParamInfo);
-  Decl::Destroy(C);
-}
-
 void BlockDecl::setParams(ParmVarDecl **NewParamInfo,
                           unsigned NParms) {
   assert(ParamInfo == 0 && "Already has param info!");
@@ -1799,15 +1728,6 @@
   return new (C) NamespaceDecl(DC, L, Id);
 }
 
-void NamespaceDecl::Destroy(ASTContext& C) {
-  // NamespaceDecl uses "NextDeclarator" to chain namespace declarations
-  // together. They are all top-level Decls.
-
-  this->~NamespaceDecl();
-  Decl::Destroy(C);
-}
-
-
 ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC,
     SourceLocation L, IdentifierInfo *Id, QualType T) {
   return new (C) ImplicitParamDecl(ImplicitParam, DC, L, Id, T);
@@ -1836,11 +1756,6 @@
   return new (C) EnumConstantDecl(CD, L, Id, T, E, V);
 }
 
-void EnumConstantDecl::Destroy(ASTContext& C) {
-  if (Init) Init->Destroy(C);
-  ValueDecl::Destroy(C);
-}
-
 TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC,
                                  SourceLocation L, IdentifierInfo *Id,
                                  TypeSourceInfo *TInfo) {

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Sun Jul 25 13:17:45 2010
@@ -157,9 +157,7 @@
 //===----------------------------------------------------------------------===//
 
 // Out-of-line virtual method providing a home for Decl.
-Decl::~Decl() {
-  assert(!HasAttrs && "attributes should have been freed by Destroy");
-}
+Decl::~Decl() { }
 
 void Decl::setDeclContext(DeclContext *DC) {
   if (isOutOfSemaDC())
@@ -372,40 +370,6 @@
   RHS->HasAttrs = true;
 }
 
-void Decl::Destroy(ASTContext &C) {
-  // Free attributes for this decl.
-  if (HasAttrs) {
-    C.getDeclAttrs(this)->Destroy(C);
-    invalidateAttrs();
-    HasAttrs = false;
-  }
-
-#if 0
-  // FIXME: Once ownership is fully understood, we can enable this code
-  if (DeclContext *DC = dyn_cast<DeclContext>(this))
-    DC->decls_begin()->Destroy(C);
-
-  // Observe the unrolled recursion.  By setting N->NextDeclInContext = 0x0
-  // within the loop, only the Destroy method for the first Decl
-  // will deallocate all of the Decls in a chain.
-
-  Decl* N = getNextDeclInContext();
-
-  while (N) {
-    Decl* Tmp = N->getNextDeclInContext();
-    N->NextDeclInContext = 0;
-    N->Destroy(C);
-    N = Tmp;
-  }
-
-  if (isOutOfSemaDC())
-    delete (C) getMultipleDC();
-  
-  this->~Decl();
-  C.Deallocate((void *)this);
-#endif  
-}
-
 Decl *Decl::castFromDeclContext (const DeclContext *D) {
   Decl::Kind DK = D->getDeclKind();
   switch(DK) {
@@ -513,11 +477,6 @@
   // delete LookupPtr;
 }
 
-void DeclContext::DestroyDecls(ASTContext &C) {
-  for (decl_iterator D = decls_begin(); D != decls_end(); )
-    (*D++)->Destroy(C);
-}
-
 /// \brief Find the parent context of this context that will be
 /// used for unqualified name lookup.
 ///
@@ -1073,7 +1032,6 @@
   // It's okay to delete DependentStoredDeclsMaps via a StoredDeclsMap
   // pointer because the subclass doesn't add anything that needs to
   // be deleted.
-  
   StoredDeclsMap::DestroyAll(LastSDM.getPointer(), LastSDM.getInt());
 }
 

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Sun Jul 25 13:17:45 2010
@@ -68,15 +68,6 @@
 CXXRecordDecl::~CXXRecordDecl() {
 }
 
-void CXXRecordDecl::Destroy(ASTContext &C) {
-  if (data().Definition == this) {
-    C.Deallocate(data().Bases);
-    C.Deallocate(data().VBases);
-    C.Deallocate(&data());
-  }
-  this->RecordDecl::Destroy(C);
-}
-
 void
 CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
                         unsigned NumBases) {
@@ -796,13 +787,6 @@
                                               L, Init, R, Indices, NumIndices);
 }
 
-void CXXBaseOrMemberInitializer::Destroy(ASTContext &Context) {
-  if (Init)
-    Init->Destroy(Context);
-  // FIXME: Destroy indices
-  this->~CXXBaseOrMemberInitializer();
-}
-
 TypeLoc CXXBaseOrMemberInitializer::getBaseClassLoc() const {
   if (isBaseInitializer())
     return BaseOrMember.get<TypeSourceInfo*>()->getTypeLoc();
@@ -959,12 +943,6 @@
   return new (C) CXXDestructorDecl(RD, L, N, T, isInline, isImplicitlyDeclared);
 }
 
-void
-CXXConstructorDecl::Destroy(ASTContext& C) {
-  C.Deallocate(BaseOrMemberInitializers);
-  CXXMethodDecl::Destroy(C);
-}
-
 CXXConversionDecl *
 CXXConversionDecl::Create(ASTContext &C, EmptyShell Empty) {
   return new (C) CXXConversionDecl(0, SourceLocation(), DeclarationName(),
@@ -1068,12 +1046,6 @@
   return new (C) StaticAssertDecl(DC, L, AssertExpr, Message);
 }
 
-void StaticAssertDecl::Destroy(ASTContext& C) {
-  AssertExpr->Destroy(C);
-  Message->Destroy(C);
-  Decl::Destroy(C);
-}
-
 StaticAssertDecl::~StaticAssertDecl() {
 }
 

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sun Jul 25 13:17:45 2010
@@ -21,14 +21,8 @@
 // ObjCListBase
 //===----------------------------------------------------------------------===//
 
-void ObjCListBase::Destroy(ASTContext &Ctx) {
-  Ctx.Deallocate(List);
-  NumElts = 0;
-  List = 0;
-}
-
 void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
-  assert(List == 0 && "Elements already set!");
+  List = 0;
   if (Elts == 0) return;  // Setting to an empty list is a noop.
 
 
@@ -47,12 +41,6 @@
   set(InList, Elts, Ctx);
 }
 
-void ObjCProtocolList::Destroy(ASTContext &Ctx) {
-  Ctx.Deallocate(Locations);
-  Locations = 0;
-  ObjCList<ObjCProtocolDecl>::Destroy(Ctx);
-}
-
 //===----------------------------------------------------------------------===//
 // ObjCInterfaceDecl
 //===----------------------------------------------------------------------===//
@@ -218,7 +206,6 @@
     ProtocolRefs.push_back(*p);
     ProtocolLocs.push_back(*pl);
   }
-  ReferencedProtocols.Destroy(C);
   unsigned NumProtoRefs = ProtocolRefs.size();
   setProtocolList(ProtocolRefs.data(), NumProtoRefs, ProtocolLocs.data(), C);
 }
@@ -350,18 +337,6 @@
                                 numSelectorArgs);
 }
 
-void ObjCMethodDecl::Destroy(ASTContext &C) {
-  if (Body) Body->Destroy(C);
-  if (SelfDecl) SelfDecl->Destroy(C);
-
-  for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
-    if (*I) (*I)->Destroy(C);
-
-  ParamInfo.Destroy(C);
-
-  Decl::Destroy(C);
-}
-
 /// \brief A definition will return its interface declaration.
 /// An interface declaration will return its definition.
 /// Otherwise it will return itself.
@@ -471,18 +446,6 @@
     ClassLoc(CLoc) {
 }
 
-void ObjCInterfaceDecl::Destroy(ASTContext &C) {
-  for (ivar_iterator I = ivar_begin(), E = ivar_end(); I != E; ++I)
-    if (*I) (*I)->Destroy(C);
-
-  // FIXME: CategoryList?
-
-  // FIXME: Because there is no clear ownership
-  //  role between ObjCInterfaceDecls and the ObjCPropertyDecls that they
-  //  reference, we destroy ObjCPropertyDecls in ~TranslationUnit.
-  Decl::Destroy(C);
-}
-
 ObjCImplementationDecl *ObjCInterfaceDecl::getImplementation() const {
   return getASTContext().getObjCImplementation(
                                           const_cast<ObjCInterfaceDecl*>(this));
@@ -633,11 +596,6 @@
   return new (C) ObjCAtDefsFieldDecl(DC, L, Id, T, BW);
 }
 
-void ObjCAtDefsFieldDecl::Destroy(ASTContext& C) {
-  this->~ObjCAtDefsFieldDecl();
-  C.Deallocate((void *)this);
-}
-
 //===----------------------------------------------------------------------===//
 // ObjCProtocolDecl
 //===----------------------------------------------------------------------===//
@@ -648,11 +606,6 @@
   return new (C) ObjCProtocolDecl(DC, L, Id);
 }
 
-void ObjCProtocolDecl::Destroy(ASTContext &C) {
-  ReferencedProtocols.Destroy(C);
-  ObjCContainerDecl::Destroy(C);
-}
-
 ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) {
   ObjCProtocolDecl *PDecl = this;
 
@@ -712,23 +665,6 @@
   return new (C) ObjCClassDecl(DC, L, Elts, Locs, nElts, C);
 }
 
-void ObjCClassDecl::Destroy(ASTContext &C) {
-  // ObjCInterfaceDecls registered with a DeclContext will get destroyed
-  // when the DeclContext is destroyed.  For those created only by a forward
-  // declaration, the first @class that created the ObjCInterfaceDecl gets
-  // to destroy it.
-  // FIXME: Note that this ownership role is very brittle; a better
-  // polict is surely need in the future.
-  for (iterator I = begin(), E = end(); I !=E ; ++I) {
-    ObjCInterfaceDecl *ID = I->getInterface();
-    if (ID->isForwardDecl() && ID->getLocStart() == getLocStart())
-      ID->Destroy(C);
-  }
-  
-  C.Deallocate(ForwardDecls);
-  Decl::Destroy(C);
-}
-
 SourceRange ObjCClassDecl::getSourceRange() const {
   // FIXME: We should include the semicolon
   assert(NumDecls);
@@ -757,11 +693,6 @@
   return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts, Locs, C);
 }
 
-void ObjCForwardProtocolDecl::Destroy(ASTContext &C) {
-  ReferencedProtocols.Destroy(C);
-  Decl::Destroy(C);
-}
-
 //===----------------------------------------------------------------------===//
 // ObjCCategoryDecl
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Sun Jul 25 13:17:45 2010
@@ -107,18 +107,6 @@
   return new (C) FunctionTemplateDecl(DC, L, Name, Params, Decl);
 }
 
-void FunctionTemplateDecl::Destroy(ASTContext &C) {
-  if (Common *CommonPtr = CommonOrPrev.dyn_cast<Common*>()) {
-    for (llvm::FoldingSet<FunctionTemplateSpecializationInfo>::iterator
-              Spec = CommonPtr->Specializations.begin(),
-           SpecEnd = CommonPtr->Specializations.end();
-         Spec != SpecEnd; ++Spec)
-      C.Deallocate(&*Spec);
-  }
-
-  Decl::Destroy(C);
-}
-
 FunctionDecl *
 FunctionTemplateDecl::findSpecialization(const TemplateArgument *Args,
                                          unsigned NumArgs, void *&InsertPos) {
@@ -177,10 +165,6 @@
   return New;
 }
 
-void ClassTemplateDecl::Destroy(ASTContext& C) {
-  Decl::Destroy(C);
-}
-
 ClassTemplateSpecializationDecl *
 ClassTemplateDecl::findSpecialization(const TemplateArgument *Args,
                                       unsigned NumArgs, void *&InsertPos) {
@@ -478,13 +462,6 @@
 StructuredArguments.setInt(0); // Doesn't own the pointer.
 }
 
-void TemplateArgumentList::Destroy(ASTContext &C) {
-  if (FlatArguments.getInt())
-    C.Deallocate((void*)FlatArguments.getPointer());
-  if (StructuredArguments.getInt())
-    C.Deallocate((void*)StructuredArguments.getPointer());
-}
-
 TemplateArgumentList::~TemplateArgumentList() {}
 
 //===----------------------------------------------------------------------===//
@@ -534,16 +511,6 @@
     new (Context)ClassTemplateSpecializationDecl(ClassTemplateSpecialization);
 }
 
-void ClassTemplateSpecializationDecl::Destroy(ASTContext &C) {
-  delete ExplicitInfo;
-
-  if (SpecializedPartialSpecialization *PartialSpec
-        = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
-    C.Deallocate(PartialSpec);
-
-  CXXRecordDecl::Destroy(C);
-}
-
 void
 ClassTemplateSpecializationDecl::getNameForDiagnostic(std::string &S,
                                                   const PrintingPolicy &Policy,

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sun Jul 25 13:17:45 2010
@@ -390,15 +390,7 @@
   return SL;
 }
 
-void StringLiteral::DoDestroy(ASTContext &C) {
-  C.Deallocate(const_cast<char*>(StrData));
-  Expr::DoDestroy(C);
-}
-
 void StringLiteral::setString(ASTContext &C, llvm::StringRef Str) {
-  if (StrData)
-    C.Deallocate(const_cast<char*>(StrData));
-
   char *AStrData = new (C, 1) char[Str.size()];
   memcpy(AStrData, Str.data(), Str.size());
   StrData = AStrData;
@@ -496,13 +488,6 @@
   SubExprs = new (C) Stmt*[1];
 }
 
-void CallExpr::DoDestroy(ASTContext& C) {
-  DestroyChildren(C);
-  if (SubExprs) C.Deallocate(SubExprs);
-  this->~CallExpr();
-  C.Deallocate(this);
-}
-
 Decl *CallExpr::getCalleeDecl() {
   Expr *CEE = getCallee()->IgnoreParenCasts();
   if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
@@ -526,8 +511,6 @@
 
   // If shrinking # arguments, just delete the extras and forgot them.
   if (NumArgs < getNumArgs()) {
-    for (unsigned i = NumArgs, e = getNumArgs(); i != e; ++i)
-      getArg(i)->Destroy(C);
     this->NumArgs = NumArgs;
     return;
   }
@@ -740,12 +723,6 @@
   return 0;
 }
 
-void CastExpr::DoDestroy(ASTContext &C)
-{
-  BasePath.Destroy();
-  Expr::DoDestroy(C);
-}
-
 Expr *CastExpr::getSubExprAsWritten() {
   Expr *SubExpr = 0;
   CastExpr *E = this;
@@ -897,9 +874,6 @@
 }
 
 void InitListExpr::resizeInits(ASTContext &C, unsigned NumInits) {
-  for (unsigned Idx = NumInits, LastIdx = InitExprs.size();
-       Idx < LastIdx; ++Idx)
-    InitExprs[Idx]->Destroy(C);
   InitExprs.resize(C, NumInits, 0);
 }
 
@@ -1775,27 +1749,6 @@
   memcpy(SubExprs, Exprs, sizeof(Expr *) * NumExprs);
 }
 
-void ShuffleVectorExpr::DoDestroy(ASTContext& C) {
-  DestroyChildren(C);
-  if (SubExprs) C.Deallocate(SubExprs);
-  this->~ShuffleVectorExpr();
-  C.Deallocate(this);
-}
-
-void SizeOfAlignOfExpr::DoDestroy(ASTContext& C) {
-  // Override default behavior of traversing children. If this has a type
-  // operand and the type is a variable-length array, the child iteration
-  // will iterate over the size expression. However, this expression belongs
-  // to the type, not to this, so we don't want to delete it.
-  // We still want to delete this expression.
-  if (isArgumentType()) {
-    this->~SizeOfAlignOfExpr();
-    C.Deallocate(this);
-  }
-  else
-    Expr::DoDestroy(C);
-}
-
 //===----------------------------------------------------------------------===//
 //  DesignatedInitExpr
 //===----------------------------------------------------------------------===//
@@ -1880,8 +1833,6 @@
 void DesignatedInitExpr::setDesignators(ASTContext &C,
                                         const Designator *Desigs,
                                         unsigned NumDesigs) {
-  DestroyDesignators(C);
-
   Designators = new (C) Designator[NumDesigs];
   NumDesignators = NumDesigs;
   for (unsigned I = 0; I != NumDesigs; ++I)
@@ -1952,23 +1903,10 @@
   std::copy(First, Last, NewDesignators + Idx);
   std::copy(Designators + Idx + 1, Designators + NumDesignators,
             NewDesignators + Idx + NumNewDesignators);
-  DestroyDesignators(C);
   Designators = NewDesignators;
   NumDesignators = NumDesignators - 1 + NumNewDesignators;
 }
 
-void DesignatedInitExpr::DoDestroy(ASTContext &C) {
-  DestroyDesignators(C);
-  Expr::DoDestroy(C);
-}
-
-void DesignatedInitExpr::DestroyDesignators(ASTContext &C) {
-  for (unsigned I = 0; I != NumDesignators; ++I)
-    Designators[I].~Designator();
-  C.Deallocate(Designators);
-  Designators = 0;
-}
-
 ParenListExpr::ParenListExpr(ASTContext& C, SourceLocation lparenloc,
                              Expr **exprs, unsigned nexprs,
                              SourceLocation rparenloc)
@@ -1982,13 +1920,6 @@
     Exprs[i] = exprs[i];
 }
 
-void ParenListExpr::DoDestroy(ASTContext& C) {
-  DestroyChildren(C);
-  if (Exprs) C.Deallocate(Exprs);
-  this->~ParenListExpr();
-  C.Deallocate(this);
-}
-
 //===----------------------------------------------------------------------===//
 //  ExprIterator.
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Sun Jul 25 13:17:45 2010
@@ -118,14 +118,6 @@
 }
 
 
-void CXXNewExpr::DoDestroy(ASTContext &C) {
-  DestroyChildren(C);
-  if (SubExprs)
-    C.Deallocate(SubExprs);
-  this->~CXXNewExpr();
-  C.Deallocate((void*)this);
-}
-
 Stmt::child_iterator CXXNewExpr::child_begin() { return &SubExprs[0]; }
 Stmt::child_iterator CXXNewExpr::child_end() {
   return &SubExprs[0] + Array + getNumPlacementArgs() + getNumConstructorArgs();
@@ -476,23 +468,11 @@
                                      SubExpr);
 }
 
-void CXXDefaultArgExpr::DoDestroy(ASTContext &C) {
-  if (Param.getInt())
-    getExpr()->Destroy(C);
-  this->~CXXDefaultArgExpr();
-  C.Deallocate(this);
-}
-
 CXXTemporary *CXXTemporary::Create(ASTContext &C,
                                    const CXXDestructorDecl *Destructor) {
   return new (C) CXXTemporary(Destructor);
 }
 
-void CXXTemporary::Destroy(ASTContext &Ctx) {
-  this->~CXXTemporary();
-  Ctx.Deallocate(this);
-}
-
 CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
                                                    CXXTemporary *Temp,
                                                    Expr* SubExpr) {
@@ -502,12 +482,6 @@
   return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
 }
 
-void CXXBindTemporaryExpr::DoDestroy(ASTContext &C) {
-  Temp->Destroy(C);
-  this->~CXXBindTemporaryExpr();
-  C.Deallocate(this);
-}
-
 CXXBindReferenceExpr *CXXBindReferenceExpr::Create(ASTContext &C, Expr *SubExpr,
                                                    bool ExtendsLifetime, 
                                                    bool RequiresTemporaryCopy) {
@@ -516,11 +490,6 @@
                                       RequiresTemporaryCopy);
 }
 
-void CXXBindReferenceExpr::DoDestroy(ASTContext &C) {
-  this->~CXXBindReferenceExpr();
-  C.Deallocate(this);
-}
-
 CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C,
                                                CXXConstructorDecl *Cons,
                                                QualType writtenTy,
@@ -569,14 +538,6 @@
   }
 }
 
-void CXXConstructExpr::DoDestroy(ASTContext &C) {
-  DestroyChildren(C);
-  if (Args)
-    C.Deallocate(Args);
-  this->~CXXConstructExpr();
-  C.Deallocate(this);
-}
-
 CXXExprWithTemporaries::CXXExprWithTemporaries(ASTContext &C,
                                                Expr *subexpr,
                                                CXXTemporary **temps,
@@ -605,14 +566,6 @@
   return new (C) CXXExprWithTemporaries(C, SubExpr, Temps, NumTemps);
 }
 
-void CXXExprWithTemporaries::DoDestroy(ASTContext &C) {
-  DestroyChildren(C);
-  if (Temps)
-    C.Deallocate(Temps);
-  this->~CXXExprWithTemporaries();
-  C.Deallocate(this);
-}
-
 CXXExprWithTemporaries::~CXXExprWithTemporaries() {}
 
 // CXXBindTemporaryExpr

Modified: cfe/trunk/lib/AST/FullExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/FullExpr.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/FullExpr.cpp (original)
+++ cfe/trunk/lib/AST/FullExpr.cpp Sun Jul 25 13:17:45 2010
@@ -43,16 +43,3 @@
   return E;
 }
 
-void FullExpr::Destroy(ASTContext &Context) {
-  if (Expr *E = SubExpr.dyn_cast<Expr *>()) {
-    E->Destroy(Context);
-    return;
-  }
-  
-  ExprAndTemporaries *ET = SubExpr.get<ExprAndTemporaries *>();
-  for (ExprAndTemporaries::temps_iterator i = ET->temps_begin(), 
-       e = ET->temps_end(); i != e; ++i)
-    (*i)->Destroy(Context);
-
-  Context.Deallocate(ET);
-}

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Sun Jul 25 13:17:45 2010
@@ -468,46 +468,6 @@
   std::copy(handlers, handlers + NumHandlers, Stmts + 1);
 }
 
-//===----------------------------------------------------------------------===//
-// AST Destruction.
-//===----------------------------------------------------------------------===//
-
-void Stmt::DestroyChildren(ASTContext &C) {
-  for (child_iterator I = child_begin(), E = child_end(); I !=E; )
-    if (Stmt* Child = *I++) Child->Destroy(C);
-}
-
-static void BranchDestroy(ASTContext &C, Stmt *S, Stmt **SubExprs,
-                          unsigned NumExprs) {
-  // We do not use child_iterator here because that will include
-  // the expressions referenced by the condition variable.
-  for (Stmt **I = SubExprs, **E = SubExprs + NumExprs; I != E; ++I)
-    if (Stmt *Child = *I) Child->Destroy(C);
-  
-  S->~Stmt();
-  C.Deallocate((void *) S);
-}
-
-void Stmt::DoDestroy(ASTContext &C) {
-  DestroyChildren(C);
-  this->~Stmt();
-  C.Deallocate((void *)this);
-}
-
-void CXXCatchStmt::DoDestroy(ASTContext& C) {
-  if (ExceptionDecl)
-    ExceptionDecl->Destroy(C);
-  Stmt::DoDestroy(C);
-}
-
-void DeclStmt::DoDestroy(ASTContext &C) {
-  // Don't use StmtIterator to iterate over the Decls, as that can recurse
-  // into VLA size expressions (which are owned by the VLA).  Further, Decls
-  // are owned by the DeclContext, and will be destroyed with them.
-  if (DG.isDeclGroup())
-    DG.getDeclGroup().Destroy(C);
-}
-
 IfStmt::IfStmt(ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond, 
                Stmt *then, SourceLocation EL, Stmt *elsev)
   : Stmt(IfStmtClass), IfLoc(IL), ElseLoc(EL)
@@ -537,10 +497,6 @@
                                    V->getSourceRange().getEnd());
 }
 
-void IfStmt::DoDestroy(ASTContext &C) {
-  BranchDestroy(C, this, SubExprs, END_EXPR);
-}
-
 ForStmt::ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, 
                  Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP, 
                  SourceLocation RP)
@@ -572,10 +528,6 @@
                                        V->getSourceRange().getEnd());
 }
 
-void ForStmt::DoDestroy(ASTContext &C) {
-  BranchDestroy(C, this, SubExprs, END_EXPR);
-}
-
 SwitchStmt::SwitchStmt(ASTContext &C, VarDecl *Var, Expr *cond) 
   : Stmt(SwitchStmtClass), FirstCase(0) 
 {
@@ -603,20 +555,6 @@
                                    V->getSourceRange().getEnd());
 }
 
-void SwitchStmt::DoDestroy(ASTContext &C) {
-  // Destroy the SwitchCase statements in this switch. In the normal
-  // case, this loop will merely decrement the reference counts from
-  // the Retain() calls in addSwitchCase();
-  SwitchCase *SC = FirstCase;
-  while (SC) {
-    SwitchCase *Next = SC->getNextSwitchCase();
-    SC->Destroy(C);
-    SC = Next;
-  }
-  
-  BranchDestroy(C, this, SubExprs, END_EXPR);
-}
-
 WhileStmt::WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body, 
                      SourceLocation WL)
 : Stmt(WhileStmtClass)
@@ -646,22 +584,6 @@
                                    V->getSourceRange().getEnd());
 }
 
-void WhileStmt::DoDestroy(ASTContext &C) {
-  BranchDestroy(C, this, SubExprs, END_EXPR);
-}
-
-void AsmStmt::DoDestroy(ASTContext &C) {
-  DestroyChildren(C);
-  
-  C.Deallocate(Names);
-  C.Deallocate(Constraints);
-  C.Deallocate(Exprs);
-  C.Deallocate(Clobbers);
-  
-  this->~AsmStmt();
-  C.Deallocate((void *)this);
-}
-
 //===----------------------------------------------------------------------===//
 //  Child Iterators for iterating over subexpressions/substatements
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sun Jul 25 13:17:45 2010
@@ -33,26 +33,6 @@
   return false;
 }
 
-void Type::Destroy(ASTContext& C) {
-  this->~Type();
-  C.Deallocate(this);
-}
-
-void VariableArrayType::Destroy(ASTContext& C) {
-  if (SizeExpr)
-    SizeExpr->Destroy(C);
-  this->~VariableArrayType();
-  C.Deallocate(this);
-}
-
-void DependentSizedArrayType::Destroy(ASTContext& C) {
-  // FIXME: Resource contention like in ConstantArrayWithExprType ?
-  // May crash, depending on platform or a particular build.
-  // SizeExpr->Destroy(C);
-  this->~DependentSizedArrayType();
-  C.Deallocate(this);
-}
-
 void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID,
                                       ASTContext &Context,
                                       QualType ET,
@@ -73,14 +53,6 @@
   SizeExpr->Profile(ID, Context, true);
 }
 
-void DependentSizedExtVectorType::Destroy(ASTContext& C) {
-  // FIXME: Deallocate size expression, once we're cloning properly.
-//  if (SizeExpr)
-//    SizeExpr->Destroy(C);
-  this->~DependentSizedExtVectorType();
-  C.Deallocate(this);
-}
-
 /// getArrayElementTypeNoTypeQual - If this is an array type, return the
 /// element type of the array, potentially with type qualifiers missing.
 /// This method should never be used when type qualifiers are meaningful.
@@ -348,11 +320,6 @@
   return 0;
 }
 
-void ObjCInterfaceType::Destroy(ASTContext& C) {
-  this->~ObjCInterfaceType();
-  C.Deallocate(this);
-}
-
 ObjCObjectType::ObjCObjectType(QualType Canonical, QualType Base,
                                ObjCProtocolDecl * const *Protocols,
                                unsigned NumProtocols)
@@ -366,11 +333,6 @@
            NumProtocols * sizeof(ObjCProtocolDecl*));
 }
 
-void ObjCObjectTypeImpl::Destroy(ASTContext& C) {
-  this->~ObjCObjectTypeImpl();
-  C.Deallocate(this);
-}
-
 const ObjCObjectType *Type::getAsObjCQualifiedInterfaceType() const {
   // There is no sugar for ObjCObjectType's, just return the canonical
   // type pointer if it is the right class.  There is no typedef information to
@@ -385,11 +347,6 @@
   return getAsObjCQualifiedInterfaceType() != 0;
 }
 
-void ObjCObjectPointerType::Destroy(ASTContext& C) {
-  this->~ObjCObjectPointerType();
-  C.Deallocate(this);
-}
-
 const ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const {
   // There is no sugar for ObjCQualifiedIdType's, just return the canonical
   // type pointer if it is the right class.
@@ -907,15 +864,6 @@
 DependentNameType::~DependentNameType() {}
 DependentTemplateSpecializationType::~DependentTemplateSpecializationType() {}
 
-void DependentTemplateSpecializationType::Destroy(ASTContext &C) {
-  for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
-    // FIXME: Not all expressions get cloned, so we can't yet perform
-    // this destruction.
-    //    if (Expr *E = getArg(Arg).getAsExpr())
-    //      E->Destroy(C);
-  }
-}
-
 DependentTemplateSpecializationType::DependentTemplateSpecializationType(
                          ElaboratedTypeKeyword Keyword,
                          NestedNameSpecifier *NNS, const IdentifierInfo *Name,
@@ -1209,15 +1157,6 @@
     new (&TemplateArgs[Arg]) TemplateArgument(Args[Arg]);
 }
 
-void TemplateSpecializationType::Destroy(ASTContext& C) {
-  for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
-    // FIXME: Not all expressions get cloned, so we can't yet perform
-    // this destruction.
-    //    if (Expr *E = getArg(Arg).getAsExpr())
-    //      E->Destroy(C);
-  }
-}
-
 void
 TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
                                     TemplateName T,

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Sun Jul 25 13:17:45 2010
@@ -2578,9 +2578,6 @@
 
   FinishFunction();
 
-  // Destroy the 'this' declaration.
-  CXXThisDecl->Destroy(getContext());
-  
   // Set the right linkage.
   CGM.setFunctionLinkage(MD, Fn);
   

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Sun Jul 25 13:17:45 2010
@@ -369,14 +369,6 @@
 
   // Emit the standard function epilogue.
   FinishFunction(BodyRange.getEnd());
-
-  // Destroy the 'this' declaration.
-  if (CXXThisDecl)
-    CXXThisDecl->Destroy(getContext());
-  
-  // Destroy the VTT declaration.
-  if (CXXVTTDecl)
-    CXXVTTDecl->Destroy(getContext());
 }
 
 /// ContainsLabel - Return true if the statement contains a label in it.  If

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Sun Jul 25 13:17:45 2010
@@ -205,10 +205,8 @@
 }
 
 void Sema::DeleteExpr(ExprTy *E) {
-  if (E) static_cast<Expr*>(E)->Destroy(Context);
 }
 void Sema::DeleteStmt(StmtTy *S) {
-  if (S) static_cast<Stmt*>(S)->Destroy(Context);
 }
 
 /// ActOnEndOfTranslationUnit - This is called at the very end of the

Modified: cfe/trunk/lib/Sema/SemaAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAttr.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAttr.cpp Sun Jul 25 13:17:45 2010
@@ -197,7 +197,6 @@
         !(Val == 0 || Val.isPowerOf2()) ||
         Val.getZExtValue() > 16) {
       Diag(PragmaLoc, diag::warn_pragma_pack_invalid_alignment);
-      Alignment->Destroy(Context);
       return; // Ignore
     }
 

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun Jul 25 13:17:45 2010
@@ -530,7 +530,6 @@
     if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
       Arg = ICE->getSubExpr();
       ICE->setSubExpr(0);
-      ICE->Destroy(Context);
       TheCall->setArg(i+1, Arg);
     }
 
@@ -736,7 +735,6 @@
       assert(Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) &&
              "promotion from float to double is the only expected cast here");
       Cast->setSubExpr(0);
-      Cast->Destroy(Context);
       TheCall->setArg(NumArgs-1, CastArg);
       OrigArg = CastArg;
     }

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Jul 25 13:17:45 2010
@@ -4731,7 +4731,6 @@
     if (!MD->isInvalidDecl())
       DiagnoseUnusedParameters(MD->param_begin(), MD->param_end());
   } else {
-    Body->Destroy(Context);
     return DeclPtrTy();
   }
 
@@ -4755,8 +4754,7 @@
     // the function body so that they aren't leaked and that the AST is well
     // formed.
     if (Body == 0) {
-      // The whole function wasn't parsed correctly, just delete this.
-      L->Destroy(Context);
+      // The whole function wasn't parsed correctly.
       continue;
     }
 
@@ -6576,7 +6574,6 @@
       else
         Diag(IdLoc, diag::err_redefinition) << Id;
       Diag(PrevDecl->getLocation(), diag::note_previous_definition);
-      if (Val) Val->Destroy(Context);
       return DeclPtrTy();
     }
   }

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Jul 25 13:17:45 2010
@@ -412,8 +412,6 @@
     for (p = 0; p <= LastMissingDefaultArg; ++p) {
       ParmVarDecl *Param = FD->getParamDecl(p);
       if (Param->hasDefaultArg()) {
-        if (!Param->hasUnparsedDefaultArg())
-          Param->getDefaultArg()->Destroy(Context);
         Param->setDefaultArg(0);
       }
     }
@@ -4584,10 +4582,8 @@
                                                 ArrayTy->getElementType(),
                                                 move(To), move(From), 
                                                 CopyingBaseSubobject, Depth+1);
-  if (Copy.isInvalid()) {
-    InitStmt->Destroy(S.Context);
+  if (Copy.isInvalid())
     return S.StmtError();
-  }
   
   // Construct the loop that copies all elements of this array.
   return S.ActOnForStmt(Loc, Loc, S.Owned(InitStmt), 

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sun Jul 25 13:17:45 2010
@@ -280,7 +280,6 @@
     PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context);
     CheckForwardProtocolDeclarationForCircularDependency(
       ProtocolName, ProtocolLoc, PDecl->getLocation(), PList);
-    PList.Destroy(Context);
 
     // Make sure the cached decl gets a valid start location.
     PDecl->setLocation(AtProtoInterfaceLoc);

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Jul 25 13:17:45 2010
@@ -553,7 +553,6 @@
   if (BaseObject) {
     // BaseObject is an anonymous struct/union variable (and is,
     // therefore, not part of another non-anonymous record).
-    if (BaseObjectExpr) BaseObjectExpr->Destroy(Context);
     MarkDeclarationReferenced(Loc, BaseObject);
     BaseObjectExpr = new (Context) DeclRefExpr(BaseObject,BaseObject->getType(),
                                                SourceLocation());
@@ -3582,9 +3581,6 @@
                                     SourceRange(Args[0]->getLocStart(),
                                                 Args[NumArgs-1]->getLocEnd()));
 
-        for (unsigned I = 0; I != NumArgs; ++I)
-          Args[I]->Destroy(Context);
-
         NumArgs = 0;
       }
 
@@ -7042,11 +7038,9 @@
       if (OC.isBrackets) {
         // Offset of an array sub-field.  TODO: Should we allow vector elements?
         const ArrayType *AT = Context.getAsArrayType(Res->getType());
-        if (!AT) {
-          Res->Destroy(Context);
+        if (!AT)
           return ExprError(Diag(OC.LocEnd, diag::err_offsetof_array_type)
                            << Res->getType());
-        }
         
         // FIXME: C++: Verify that operator[] isn't overloaded.
         
@@ -7068,11 +7062,9 @@
       }
       
       const RecordType *RC = Res->getType()->getAs<RecordType>();
-      if (!RC) {
-        Res->Destroy(Context);
+      if (!RC)
         return ExprError(Diag(OC.LocEnd, diag::err_offsetof_record_type)
                          << Res->getType());
-      }
       
       // Get the decl corresponding to this.
       RecordDecl *RD = RC->getDecl();
@@ -7986,10 +7978,8 @@
   if (!Sub)
     return ExprError();
   
-  if (CheckBooleanCondition(Sub, Loc)) {
-    Sub->Destroy(Context);
+  if (CheckBooleanCondition(Sub, Loc))
     return ExprError();
-  }
   
   return Owned(Sub);
 }

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun Jul 25 13:17:45 2010
@@ -1491,10 +1491,8 @@
   Expr *Condition = DeclRefExpr::Create(Context, 0, SourceRange(), ConditionVar,
                                         ConditionVar->getLocation(), 
                                  ConditionVar->getType().getNonReferenceType());
-  if (ConvertToBoolean && CheckBooleanCondition(Condition, StmtLoc)) {
-    Condition->Destroy(Context);
+  if (ConvertToBoolean && CheckBooleanCondition(Condition, StmtLoc))
     return ExprError();
-  }
   
   return Owned(Condition);
 }

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Sun Jul 25 13:17:45 2010
@@ -55,9 +55,6 @@
 
       // Get the locations of the string tokens.
       StrLocs.append(S->tokloc_begin(), S->tokloc_end());
-
-      // Free the temporary string.
-      S->Destroy(Context);
     }
 
     // Create the aggregate string with the appropriate content and location
@@ -762,11 +759,8 @@
   unsigned NumArgs = ArgsIn.size();
   Expr **Args = reinterpret_cast<Expr **>(ArgsIn.release());
   if (CheckMessageArgumentTypes(Args, NumArgs, Sel, Method, true,
-                                LBracLoc, RBracLoc, ReturnType)) {
-    for (unsigned I = 0; I != NumArgs; ++I)
-      Args[I]->Destroy(Context);
+                                LBracLoc, RBracLoc, ReturnType))
     return ExprError();
-  }
 
   // Construct the appropriate ObjCMessageExpr.
   Expr *Result;

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sun Jul 25 13:17:45 2010
@@ -6407,14 +6407,6 @@
                                          PartialOverloading);  
 }
 
-static Sema::OwningExprResult Destroy(Sema &SemaRef, Expr *Fn,
-                                      Expr **Args, unsigned NumArgs) {
-  Fn->Destroy(SemaRef.Context);
-  for (unsigned Arg = 0; Arg < NumArgs; ++Arg)
-    Args[Arg]->Destroy(SemaRef.Context);
-  return SemaRef.ExprError();
-}
-
 /// Attempts to recover from a call where no functions were found.
 ///
 /// Returns true if new candidates were found.
@@ -6442,7 +6434,7 @@
   LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
                  Sema::LookupOrdinaryName);
   if (SemaRef.DiagnoseEmptyLookup(S, SS, R, Sema::CTC_Expression))
-    return Destroy(SemaRef, Fn, Args, NumArgs);
+    return SemaRef.ExprError();
 
   assert(!R.empty() && "lookup results empty despite recovery");
 
@@ -6457,9 +6449,7 @@
     NewFn = SemaRef.BuildDeclarationNameExpr(SS, R, false);
 
   if (NewFn.isInvalid())
-    return Destroy(SemaRef, Fn, Args, NumArgs);
-
-  Fn->Destroy(SemaRef.Context);
+    return SemaRef.ExprError();
 
   // This shouldn't cause an infinite loop because we're giving it
   // an expression with non-empty lookup results, which should never
@@ -6545,11 +6535,7 @@
     break;
   }
 
-  // Overload resolution failed. Destroy all of the subexpressions and
-  // return NULL.
-  Fn->Destroy(Context);
-  for (unsigned Arg = 0; Arg < NumArgs; ++Arg)
-    Args[Arg]->Destroy(Context);
+  // Overload resolution failed.
   return ExprError();
 }
 
@@ -7374,14 +7360,8 @@
     break;
   }
 
-  if (Best == CandidateSet.end()) {
-    // We had an error; delete all of the subexpressions and return
-    // the error.
-    Object->Destroy(Context);
-    for (unsigned ArgIdx = 0; ArgIdx < NumArgs; ++ArgIdx)
-      Args[ArgIdx]->Destroy(Context);
+  if (Best == CandidateSet.end())
     return true;
-  }
 
   if (Best->Function == 0) {
     // Since there is no function declaration, this is one of the

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sun Jul 25 13:17:45 2010
@@ -458,10 +458,8 @@
   SS->setBody(BodyStmt, SwitchLoc);
   getSwitchStack().pop_back();
 
-  if (SS->getCond() == 0) {
-    SS->Destroy(Context);
+  if (SS->getCond() == 0)
     return StmtError();
-  }
     
   Expr *CondExpr = SS->getCond();
   Expr *CondExprBeforePromotion = CondExpr;
@@ -1086,7 +1084,6 @@
   if (CurBlock->ReturnType->isVoidType()) {
     if (RetValExp) {
       Diag(ReturnLoc, diag::err_return_block_has_expr);
-      RetValExp->Destroy(Context);
       RetValExp = 0;
     }
     Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, 0);

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sun Jul 25 13:17:45 2010
@@ -1102,7 +1102,6 @@
           DiagnoseDefaultTemplateArgument(*this, TPC, 
                                           NewNonTypeParm->getLocation(), 
                     NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
-        NewNonTypeParm->getDefaultArgument()->Destroy(Context);
         NewNonTypeParm->removeDefaultArgument();
       }
 
@@ -3660,7 +3659,6 @@
                diag::err_default_arg_in_partial_spec)
             << DefArg->getSourceRange();
           NTTP->removeDefaultArgument();
-          DefArg->Destroy(Context);
         }
       } else {
         TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(Param);

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Sun Jul 25 13:17:45 2010
@@ -1718,13 +1718,8 @@
   }
 
   // Clean up if we had an error.
-  if (Invalid) {
-    for (ParamVector::iterator PI = Params.begin(), PE = Params.end();
-         PI != PE; ++PI)
-      if (*PI)
-        (*PI)->Destroy(SemaRef.Context);
+  if (Invalid)
     return NULL;
-  }
 
   TemplateParameterList *InstL
     = TemplateParameterList::Create(SemaRef.Context, L->getTemplateLoc(),

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Sun Jul 25 13:17:45 2010
@@ -672,7 +672,6 @@
       !ArraySize->getType()->isIntegerType()) {
     Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
       << ArraySize->getType() << ArraySize->getSourceRange();
-    ArraySize->Destroy(Context);
     return QualType();
   }
   llvm::APSInt ConstVal(32);

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=109377&r1=109376&r2=109377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Sun Jul 25 13:17:45 2010
@@ -4116,20 +4116,14 @@
                                             ExceptionDecl->getLocation(),
                                             /*FIXME: Inaccurate*/
                                     SourceRange(ExceptionDecl->getLocation()));
-    if (!Var || Var->isInvalidDecl()) {
-      if (Var)
-        Var->Destroy(SemaRef.Context);
+    if (!Var || Var->isInvalidDecl())
       return SemaRef.StmtError();
-    }
   }
 
   // Transform the actual exception handler.
   OwningStmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
-  if (Handler.isInvalid()) {
-    if (Var)
-      Var->Destroy(SemaRef.Context);
+  if (Handler.isInvalid())
     return SemaRef.StmtError();
-  }
 
   if (!getDerived().AlwaysRebuild() &&
       !Var &&





More information about the cfe-commits mailing list