From 6bd44afc2fb4c7a477257a76cbd82bfb007c046f Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 8 Aug 2008 14:08:55 +0000 Subject: [PATCH] Destroy and delete the FieldDecl members of a RecordDecl. llvm-svn: 54527 --- clang/include/clang/AST/Decl.h | 4 ++++ clang/lib/AST/Decl.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 3b340393cfdd..1ab8a59611c8 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -808,6 +808,10 @@ protected: Members = 0; NumMembers = -1; } + + virtual ~RecordDecl(); + virtual void Destroy(ASTContext& C); + public: static RecordDecl *Create(ASTContext &C, TagKind TK, DeclContext *DC, diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index a2b39c438d53..7930c9095377 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -217,6 +217,19 @@ unsigned FunctionDecl::getMinRequiredArguments() const { // RecordDecl Implementation //===----------------------------------------------------------------------===// +RecordDecl::~RecordDecl() { + delete[] Members; +} + +void RecordDecl::Destroy(ASTContext& C) { + if (isDefinition()) + for (field_iterator I=field_begin(), E=field_end(); I!=E; ++I) + (*I)->Destroy(C); + + TagDecl::Destroy(C); +} + + /// defineBody - When created, RecordDecl's correspond to a forward declared /// record. This method is used to mark the decl as being defined, with the /// specified contents.