When destroying DeclStmts, also destroy the associated Decl (reclaim its memory).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51379 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 8b29617..c854bb5 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -146,6 +146,8 @@
DeclStmt(ScopedDecl *D, SourceLocation startLoc, SourceLocation endLoc)
: Stmt(DeclStmtClass), TheDecl(D), StartLoc(startLoc), EndLoc(endLoc) {}
+ virtual void Destroy(ASTContext& Ctx);
+
const ScopedDecl *getDecl() const { return TheDecl; }
ScopedDecl *getDecl() { return TheDecl; }
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 6ed9966..b12518f 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -55,6 +55,11 @@
delete this;
}
+void DeclStmt::Destroy(ASTContext& C) {
+ TheDecl->Destroy(C);
+ Stmt::Destroy(C);
+}
+
void Stmt::PrintStats() {
// Ensure the table is primed.
getStmtInfoTableEntry(Stmt::NullStmtClass);