From: Sam Bishop Date: Fri, 11 Apr 2008 15:01:25 +0000 (+0000) Subject: Stub out and start using a Decl::Destroy() method. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb45c512e0dfbe96bfe377ac642e726c0ba0affa;p=clang Stub out and start using a Decl::Destroy() method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49532 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index d1b48b8a62..ec3c753051 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -179,6 +179,9 @@ public: /// Create - Deserialize a Decl from Bitcode. static Decl* Create(llvm::Deserializer& D, ASTContext& C); + /// Destroy - Call destructors and release memory. + void Destroy(ASTContext& C) const; + protected: /// EmitImpl - Provides the subclass-specific serialization logic for /// serializing out a decl. diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 2ef31e42e5..43da07cc24 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -329,6 +329,10 @@ const Attr *Decl::getAttrs() const { return (*DeclAttrs)[this]; } +void Decl::Destroy(ASTContext& C) const { + C.getAllocator().Deallocate((void *)this); +} + //===----------------------------------------------------------------------===// // DeclContext Implementation //===----------------------------------------------------------------------===// diff --git a/lib/AST/TranslationUnit.cpp b/lib/AST/TranslationUnit.cpp index b3a2e68f60..0198f6f1cf 100644 --- a/lib/AST/TranslationUnit.cpp +++ b/lib/AST/TranslationUnit.cpp @@ -32,7 +32,7 @@ enum { BasicMetadataBlock = 1, TranslationUnit::~TranslationUnit() { for (iterator I=begin(), E=end(); I!=E; ++I) - delete *I; + (*I)->Destroy(*Context); } bool clang::EmitASTBitcodeFile(const TranslationUnit& TU,