aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 43da07cc24..c0ec3085e5 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -329,10 +329,43 @@ const Attr *Decl::getAttrs() const {
return (*DeclAttrs)[this];
}
+#define CASE(KIND) case KIND: cast<KIND##Decl>(this)->~KIND##Decl(); break
+
void Decl::Destroy(ASTContext& C) const {
+ switch (getKind()) {
+ CASE(Field);
+ CASE(ObjCIvar);
+ CASE(ObjCCategory);
+ CASE(ObjCCategoryImpl);
+ CASE(ObjCImplementation);
+ CASE(ObjCProtocol);
+ CASE(ObjCProperty);
+ CASE(Typedef);
+ CASE(Enum);
+ CASE(EnumConstant);
+ CASE(Function);
+ CASE(BlockVar);
+ CASE(FileVar);
+ CASE(ParmVar);
+ CASE(ObjCInterface);
+ CASE(ObjCCompatibleAlias);
+ CASE(ObjCMethod);
+ CASE(ObjCClass);
+ CASE(ObjCForwardProtocol);
+ CASE(LinkageSpec);
+
+ case Struct: case Union: case Class:
+ cast<RecordDecl>(this)->~RecordDecl();
+ break;
+
+ default: assert(0 && "Unknown decl kind!");
+ }
+
C.getAllocator().Deallocate((void *)this);
}
+#undef CASE
+
//===----------------------------------------------------------------------===//
// DeclContext Implementation
//===----------------------------------------------------------------------===//