From 1287ce6562613d656bb3d74af21326bf91183ffa Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 7 Jun 2009 09:33:57 +0000 Subject: Don't delete decls before parsing is complete. git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@73023 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/kleaver/main.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/kleaver/main.cpp b/tools/kleaver/main.cpp index 9699dcfd..83e74f79 100644 --- a/tools/kleaver/main.cpp +++ b/tools/kleaver/main.cpp @@ -76,12 +76,13 @@ static void PrintInputTokens(const MemoryBuffer *MB) { static bool PrintInputAST(const char *Filename, const MemoryBuffer *MB) { + std::vector Decls; Parser *P = Parser::Create(Filename, MB); P->SetMaxErrors(20); while (Decl *D = P->ParseTopLevelDecl()) { if (!P->GetNumErrors()) D->dump(); - delete D; + Decls.push_back(D); } bool success = true; @@ -90,6 +91,11 @@ static bool PrintInputAST(const char *Filename, << N << " errors.\n"; success = false; } + + for (std::vector::iterator it = Decls.begin(), + ie = Decls.end(); it != ie; ++it) + delete *it; + delete P; return success; @@ -110,14 +116,6 @@ static bool EvaluateInputAST(const char *Filename, << N << " errors.\n"; success = false; } - delete P; - - if (!success) { - for (std::vector::iterator it = Decls.begin(), - ie = Decls.end(); it != ie; ++it) - delete *it; - return success; - } // FIXME: Support choice of solver. Solver *S, *STP = new STPSolver(true); @@ -186,10 +184,13 @@ static bool EvaluateInputAST(const char *Filename, llvm::cout << "\n"; ++Index; } - - delete D; } + for (std::vector::iterator it = Decls.begin(), + ie = Decls.end(); it != ie; ++it) + delete *it; + delete P; + delete S; return success; -- cgit 1.4.1