summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/DeclBase.h3
-rw-r--r--clang/lib/AST/Decl.cpp4
-rw-r--r--clang/lib/AST/TranslationUnit.cpp2
3 files changed, 8 insertions, 1 deletions
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h
index d1b48b8a621..ec3c753051c 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/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/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 2ef31e42e54..43da07cc245 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/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/clang/lib/AST/TranslationUnit.cpp b/clang/lib/AST/TranslationUnit.cpp
index b3a2e68f60c..0198f6f1cf7 100644
--- a/clang/lib/AST/TranslationUnit.cpp
+++ b/clang/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,
OpenPOWER on IntegriCloud