diff options
author | Oscar Deits <odeits@vidder.com> | 2017-08-27 23:19:29 -0400 |
---|---|---|
committer | Oscar Deits <odeits@vidder.com> | 2017-08-27 23:19:29 -0400 |
commit | b5929722363993bf0ad2a56d66176606cc742bc4 (patch) | |
tree | b6dce38dd98d681e97d08d0b42adff078ccf7215 | |
parent | d19500eb93083c8cc6bb72bcb54414015830cacb (diff) | |
download | klee-b5929722363993bf0ad2a56d66176606cc742bc4.tar.gz |
Remove unnecessary null pointer checks
Fixes klee/klee#717 delete on null pointer is always safe.
-rw-r--r-- | include/klee/Internal/ADT/DiscretePDF.inc | 6 | ||||
-rw-r--r-- | lib/Basic/Statistics.cpp | 8 | ||||
-rw-r--r-- | lib/Core/Executor.cpp | 13 | ||||
-rw-r--r-- | lib/Core/Memory.cpp | 12 | ||||
-rw-r--r-- | lib/Core/StatsTracker.cpp | 6 | ||||
-rw-r--r-- | lib/Expr/ExprSMTLIBPrinter.cpp | 6 | ||||
-rw-r--r-- | lib/Module/RaiseAsm.cpp | 3 | ||||
-rw-r--r-- | lib/Support/FileHandling.cpp | 3 | ||||
-rw-r--r-- | lib/Support/TreeStream.cpp | 3 | ||||
-rw-r--r-- | tools/klee/main.cpp | 4 |
10 files changed, 26 insertions, 38 deletions
diff --git a/include/klee/Internal/ADT/DiscretePDF.inc b/include/klee/Internal/ADT/DiscretePDF.inc index eb7bd860..32328c95 100644 --- a/include/klee/Internal/ADT/DiscretePDF.inc +++ b/include/klee/Internal/ADT/DiscretePDF.inc @@ -53,8 +53,8 @@ DiscretePDF<T>::Node::Node(T key_, weight_type weight_, Node *parent_) { template <class T> DiscretePDF<T>::Node::~Node() { - if (left) delete left; - if (right) delete right; + delete left; + delete right; } // @@ -66,7 +66,7 @@ DiscretePDF<T>::DiscretePDF() { template <class T> DiscretePDF<T>::~DiscretePDF() { - if (m_root) delete m_root; + delete m_root; } template <class T> diff --git a/lib/Basic/Statistics.cpp b/lib/Basic/Statistics.cpp index 9c95a891..402b0e5a 100644 --- a/lib/Basic/Statistics.cpp +++ b/lib/Basic/Statistics.cpp @@ -22,18 +22,18 @@ StatisticManager::StatisticManager() } StatisticManager::~StatisticManager() { - if (globalStats) delete[] globalStats; - if (indexedStats) delete[] indexedStats; + delete[] globalStats; + delete[] indexedStats; } void StatisticManager::useIndexedStats(unsigned totalIndices) { - if (indexedStats) delete[] indexedStats; + delete[] indexedStats; indexedStats = new uint64_t[totalIndices * stats.size()]; memset(indexedStats, 0, sizeof(*indexedStats) * totalIndices * stats.size()); } void StatisticManager::registerStatistic(Statistic &s) { - if (globalStats) delete[] globalStats; + delete[] globalStats; s.id = stats.size(); stats.push_back(&s); globalStats = new uint64_t[stats.size()]; diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index fac68b8d..a0a6f7ea 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -419,21 +419,16 @@ const Module *Executor::setModule(llvm::Module *module, Executor::~Executor() { delete memory; delete externalDispatcher; - if (processTree) - delete processTree; - if (specialFunctionHandler) - delete specialFunctionHandler; - if (statsTracker) - delete statsTracker; + delete processTree; + delete specialFunctionHandler; + delete statsTracker; delete solver; delete kmodule; while(!timers.empty()) { delete timers.back(); timers.pop_back(); } - if (debugInstFile) { - delete debugInstFile; - } + delete debugInstFile; } /***/ diff --git a/lib/Core/Memory.cpp b/lib/Core/Memory.cpp index 0d354bf3..584ea15d 100644 --- a/lib/Core/Memory.cpp +++ b/lib/Core/Memory.cpp @@ -155,9 +155,9 @@ ObjectState::ObjectState(const ObjectState &os) } ObjectState::~ObjectState() { - if (concreteMask) delete concreteMask; - if (flushMask) delete flushMask; - if (knownSymbolics) delete[] knownSymbolics; + delete concreteMask; + delete flushMask; + delete[] knownSymbolics; delete[] concreteStore; if (object) @@ -230,9 +230,9 @@ const UpdateList &ObjectState::getUpdates() const { } void ObjectState::makeConcrete() { - if (concreteMask) delete concreteMask; - if (flushMask) delete flushMask; - if (knownSymbolics) delete[] knownSymbolics; + delete concreteMask; + delete flushMask; + delete[] knownSymbolics; concreteMask = 0; flushMask = 0; knownSymbolics = 0; diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index 3a87f57a..6dc13df8 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -264,10 +264,8 @@ StatsTracker::StatsTracker(Executor &_executor, std::string _objectFilename, } StatsTracker::~StatsTracker() { - if (statsFile) - delete statsFile; - if (istatsFile) - delete istatsFile; + delete statsFile; + delete istatsFile; } void StatsTracker::done() { diff --git a/lib/Expr/ExprSMTLIBPrinter.cpp b/lib/Expr/ExprSMTLIBPrinter.cpp index 192e3461..fd515509 100644 --- a/lib/Expr/ExprSMTLIBPrinter.cpp +++ b/lib/Expr/ExprSMTLIBPrinter.cpp @@ -61,14 +61,12 @@ ExprSMTLIBPrinter::ExprSMTLIBPrinter() } ExprSMTLIBPrinter::~ExprSMTLIBPrinter() { - if (p != NULL) - delete p; + delete p; } void ExprSMTLIBPrinter::setOutput(llvm::raw_ostream &output) { o = &output; - if (p != NULL) - delete p; + delete p; p = new PrintContext(output); } diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index 22c51e18..13e4f7d4 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -103,8 +103,7 @@ bool RaiseAsmPass::runOnModule(Module &M) { } } - if (TM) - delete TM; + delete TM; return changed; } diff --git a/lib/Support/FileHandling.cpp b/lib/Support/FileHandling.cpp index e5ead9f7..3e156f3c 100644 --- a/lib/Support/FileHandling.cpp +++ b/lib/Support/FileHandling.cpp @@ -31,8 +31,7 @@ llvm::raw_fd_ostream *klee_open_output_file(std::string &path, f = new llvm::raw_fd_ostream(path.c_str(), error, llvm::sys::fs::F_Binary); #endif if (!error.empty()) { - if (f) - delete f; + delete f; f = NULL; } return f; diff --git a/lib/Support/TreeStream.cpp b/lib/Support/TreeStream.cpp index a0e1596f..8681245b 100644 --- a/lib/Support/TreeStream.cpp +++ b/lib/Support/TreeStream.cpp @@ -40,8 +40,7 @@ TreeStreamWriter::TreeStreamWriter(const std::string &_path) TreeStreamWriter::~TreeStreamWriter() { flush(); - if (output) - delete output; + delete output; } bool TreeStreamWriter::good() { diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index 05ba54d3..f1def38c 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -333,8 +333,8 @@ KleeHandler::KleeHandler(int argc, char **argv) } KleeHandler::~KleeHandler() { - if (m_pathWriter) delete m_pathWriter; - if (m_symPathWriter) delete m_symPathWriter; + delete m_pathWriter; + delete m_symPathWriter; fclose(klee_warning_file); fclose(klee_message_file); delete m_infoFile; |