about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorOscar Deits <odeits@vidder.com>2017-08-27 23:19:29 -0400
committerOscar Deits <odeits@vidder.com>2017-08-27 23:19:29 -0400
commitb5929722363993bf0ad2a56d66176606cc742bc4 (patch)
treeb6dce38dd98d681e97d08d0b42adff078ccf7215 /lib
parentd19500eb93083c8cc6bb72bcb54414015830cacb (diff)
downloadklee-b5929722363993bf0ad2a56d66176606cc742bc4.tar.gz
Remove unnecessary null pointer checks
Fixes klee/klee#717

delete on null pointer is always safe.
Diffstat (limited to 'lib')
-rw-r--r--lib/Basic/Statistics.cpp8
-rw-r--r--lib/Core/Executor.cpp13
-rw-r--r--lib/Core/Memory.cpp12
-rw-r--r--lib/Core/StatsTracker.cpp6
-rw-r--r--lib/Expr/ExprSMTLIBPrinter.cpp6
-rw-r--r--lib/Module/RaiseAsm.cpp3
-rw-r--r--lib/Support/FileHandling.cpp3
-rw-r--r--lib/Support/TreeStream.cpp3
8 files changed, 21 insertions, 33 deletions
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() {