about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-07 09:33:57 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-07 09:33:57 +0000
commit1287ce6562613d656bb3d74af21326bf91183ffa (patch)
treecf67f4c066c2dc6aa8c5853fdf6400492c33a69e
parent94180dea607cb1cf2d762392a2fdd482125c4bc4 (diff)
downloadklee-1287ce6562613d656bb3d74af21326bf91183ffa.tar.gz
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
-rw-r--r--tools/kleaver/main.cpp23
1 files 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<Decl*> 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<Decl*>::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<Decl*>::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<Decl*>::iterator it = Decls.begin(),
+         ie = Decls.end(); it != ie; ++it)
+    delete *it;
+  delete P;
+
   delete S;
 
   return success;