From: Douglas Gregor Date: Sun, 25 Jul 2010 18:32:30 +0000 (+0000) Subject: I lied. Kill off a few more Destroy methods X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1de22a26c0e126b08edb2eda9d9091c021d96dc6;p=clang I lied. Kill off a few more Destroy methods git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109379 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 9faa62eef6..f06c4ab25f 100644 --- a/include/clang/AST/Attr.h +++ b/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/include/clang/AST/DeclGroup.h b/include/clang/AST/DeclGroup.h index e1fae8f2ae..030291ea73 100644 --- a/include/clang/AST/DeclGroup.h +++ b/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/lib/AST/AttrImpl.cpp b/lib/AST/AttrImpl.cpp index b09ba895c0..7277bbce24 100644 --- a/lib/AST/AttrImpl.cpp +++ b/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/lib/AST/DeclGroup.cpp b/lib/AST/DeclGroup.cpp index 434bf00d35..036acc2d77 100644 --- a/lib/AST/DeclGroup.cpp +++ b/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); -}