From 2b34877c5dbf24eabf331a124b1e68d901a72cba Mon Sep 17 00:00:00 2001 From: Julian Büning Date: Wed, 3 Oct 2018 14:42:37 +0200 Subject: refactor klee_open_output_file to return std::unique_ptr and introduce klee_open_compressed_output_file with similar behavior along some other minor improvements --- lib/Core/ExecutorTimers.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'lib/Core/ExecutorTimers.cpp') diff --git a/lib/Core/ExecutorTimers.cpp b/lib/Core/ExecutorTimers.cpp index dd0d824e..a3c13530 100644 --- a/lib/Core/ExecutorTimers.cpp +++ b/lib/Core/ExecutorTimers.cpp @@ -116,28 +116,25 @@ void Executor::processTimers(ExecutionState *current, if (dumpPTree) { char name[32]; sprintf(name, "ptree%08d.dot", (int) stats::instructions); - llvm::raw_ostream *os = interpreterHandler->openOutputFile(name); + auto os = interpreterHandler->openOutputFile(name); if (os) { processTree->dump(*os); - delete os; } - + dumpPTree = 0; } if (dumpStates) { - llvm::raw_ostream *os = interpreterHandler->openOutputFile("states.txt"); - + auto os = interpreterHandler->openOutputFile("states.txt"); + if (os) { - for (std::set::const_iterator it = states.begin(), - ie = states.end(); it != ie; ++it) { - ExecutionState *es = *it; + for (ExecutionState *es : states) { *os << "(" << es << ","; *os << "["; - ExecutionState::stack_ty::iterator next = es->stack.begin(); + auto next = es->stack.begin(); ++next; - for (ExecutionState::stack_ty::iterator sfIt = es->stack.begin(), - sf_ie = es->stack.end(); sfIt != sf_ie; ++sfIt) { + for (auto sfIt = es->stack.begin(), sf_ie = es->stack.end(); + sfIt != sf_ie; ++sfIt) { *os << "('" << sfIt->kf->function->getName().str() << "',"; if (next == es->stack.end()) { *os << es->prevPC->info->line << "), "; @@ -167,8 +164,6 @@ void Executor::processTimers(ExecutionState *current, *os << "}"; *os << ")\n"; } - - delete os; } dumpStates = 0; -- cgit 1.4.1