From 717ceeae7671330996cc577ceea4ab2c63fb940f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 25 Jul 2010 18:32:30 +0000 Subject: [PATCH] I lied. Kill off a few more Destroy methods llvm-svn: 109379 --- clang/include/clang/AST/Attr.h | 13 +++---------- clang/include/clang/AST/DeclGroup.h | 1 - clang/lib/AST/AttrImpl.cpp | 20 +------------------- clang/lib/AST/DeclGroup.cpp | 6 ------ 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h index 9faa62eef6f7..f06c4ab25f09 100644 --- a/clang/include/clang/AST/Attr.h +++ b/clang/include/clang/AST/Attr.h @@ -49,6 +49,8 @@ private: bool Inherited : 1; protected: + virtual ~Attr(); + void* operator new(size_t bytes) throw() { assert(0 && "Attrs cannot be allocated with regular 'new'."); return 0; @@ -59,11 +61,8 @@ protected: protected: Attr(attr::Kind AK) : Next(0), AttrKind(AK), Inherited(false) {} - virtual ~Attr() { - assert(Next == 0 && "Destroy didn't work"); - } + public: - virtual void Destroy(ASTContext &C); /// \brief Whether this attribute should be merged to new /// declarations. @@ -110,8 +109,6 @@ protected: AttrWithString(attr::Kind AK, ASTContext &C, llvm::StringRef s); llvm::StringRef getString() const { return llvm::StringRef(Str, StrLen); } void ReplaceString(ASTContext &C, llvm::StringRef newS); -public: - virtual void Destroy(ASTContext &C); }; #define DEF_SIMPLE_ATTR(ATTR) \ @@ -357,8 +354,6 @@ class NonNullAttr : public Attr { public: NonNullAttr(ASTContext &C, unsigned* arg_nums = 0, unsigned size = 0); - virtual void Destroy(ASTContext &C); - typedef const unsigned *iterator; iterator begin() const { return ArgNums; } iterator end() const { return ArgNums + Size; } @@ -545,8 +540,6 @@ public: InitPriorityAttr(unsigned priority) : Attr(attr::InitPriority), Priority(priority) {} - virtual void Destroy(ASTContext &C) { Attr::Destroy(C); } - unsigned getPriority() const { return Priority; } virtual Attr *clone(ASTContext &C) const; diff --git a/clang/include/clang/AST/DeclGroup.h b/clang/include/clang/AST/DeclGroup.h index e1fae8f2ae67..030291ea7345 100644 --- a/clang/include/clang/AST/DeclGroup.h +++ b/clang/include/clang/AST/DeclGroup.h @@ -34,7 +34,6 @@ private: public: static DeclGroup *Create(ASTContext &C, Decl **Decls, unsigned NumDecls); - void Destroy(ASTContext& C); unsigned size() const { return NumDecls; } diff --git a/clang/lib/AST/AttrImpl.cpp b/clang/lib/AST/AttrImpl.cpp index b09ba895c019..7277bbce24bb 100644 --- a/clang/lib/AST/AttrImpl.cpp +++ b/clang/lib/AST/AttrImpl.cpp @@ -15,14 +15,7 @@ #include "clang/AST/ASTContext.h" using namespace clang; -void Attr::Destroy(ASTContext &C) { - if (Next) { - Next->Destroy(C); - Next = 0; - } - this->~Attr(); - C.Deallocate((void*)this); -} +Attr::~Attr() { } AttrWithString::AttrWithString(attr::Kind AK, ASTContext &C, llvm::StringRef s) : Attr(AK) { @@ -32,11 +25,6 @@ AttrWithString::AttrWithString(attr::Kind AK, ASTContext &C, llvm::StringRef s) memcpy(const_cast(Str), s.data(), StrLen); } -void AttrWithString::Destroy(ASTContext &C) { - C.Deallocate(const_cast(Str)); - Attr::Destroy(C); -} - void AttrWithString::ReplaceString(ASTContext &C, llvm::StringRef newS) { if (newS.size() > StrLen) { C.Deallocate(const_cast(Str)); @@ -60,12 +48,6 @@ NonNullAttr::NonNullAttr(ASTContext &C, unsigned* arg_nums, unsigned size) memcpy(ArgNums, arg_nums, sizeof(*ArgNums)*size); } -void NonNullAttr::Destroy(ASTContext &C) { - if (ArgNums) - C.Deallocate(ArgNums); - Attr::Destroy(C); -} - #define DEF_SIMPLE_ATTR_CLONE(ATTR) \ Attr *ATTR##Attr::clone(ASTContext &C) const { \ return ::new (C) ATTR##Attr; \ diff --git a/clang/lib/AST/DeclGroup.cpp b/clang/lib/AST/DeclGroup.cpp index 434bf00d354e..036acc2d77a5 100644 --- a/clang/lib/AST/DeclGroup.cpp +++ b/clang/lib/AST/DeclGroup.cpp @@ -30,9 +30,3 @@ DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) { assert(decls); memcpy(this+1, decls, numdecls * sizeof(*decls)); } - -void DeclGroup::Destroy(ASTContext& C) { - // Decls are destroyed by the DeclContext. - this->~DeclGroup(); - C.Deallocate((void*) this); -}