diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index b95ff3e180af..04ee44a480a8 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -212,12 +212,14 @@ VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, } void VarDecl::Destroy(ASTContext& C) { + Expr *Init = getInit(); + if (Init) + Init->Destroy(C); this->~VarDecl(); C.Deallocate((void *)this); } VarDecl::~VarDecl() { - delete getInit(); } //===----------------------------------------------------------------------===// diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index dbc811a68b11..b328c1ef3dac 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -17,7 +17,9 @@ using namespace clang; void CXXConditionDeclExpr::Destroy(ASTContext& C) { - getVarDecl()->Destroy(C); + // FIXME: Cannot destroy the decl here, because it is linked into the + // DeclContext's chain. + //getVarDecl()->Destroy(C); delete this; }