From f31ecd39273231fccc53785f518023d70f85a02a Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Mon, 9 Jun 2014 22:53:16 +0000 Subject: Removing an "if (!this)" check from two print methods. The condition will never be true in a well-defined context. The checking for null pointers has been moved into the caller logic so it does not rely on undefined behavior. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210497 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/IPA/CallGraphSCCPass.cpp | 4 +++- lib/Analysis/IVUsers.cpp | 1 + lib/Analysis/LoopPass.cpp | 1 + lib/Analysis/RegionPass.cpp | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/Analysis') diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index bfab744d47..0d9d0ef842 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -602,8 +602,10 @@ namespace { bool runOnSCC(CallGraphSCC &SCC) override { Out << Banner; - for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) + for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) { + assert((*I)->getFunction() && "Expecting non-null Function"); (*I)->getFunction()->print(Out); + } return false; } }; diff --git a/lib/Analysis/IVUsers.cpp b/lib/Analysis/IVUsers.cpp index c819bd319c..0b94238e66 100644 --- a/lib/Analysis/IVUsers.cpp +++ b/lib/Analysis/IVUsers.cpp @@ -287,6 +287,7 @@ void IVUsers::print(raw_ostream &OS, const Module *M) const { OS << ")"; } OS << " in "; + assert(UI->getUser() != nullptr && "Expected non-null User"); UI->getUser()->print(OS); OS << '\n'; } diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp index 8df18e75c6..2c6e6e3fff 100644 --- a/lib/Analysis/LoopPass.cpp +++ b/lib/Analysis/LoopPass.cpp @@ -45,6 +45,7 @@ public: for (Loop::block_iterator b = L->block_begin(), be = L->block_end(); b != be; ++b) { + assert((*b) != nullptr && "Expecting non-null block"); (*b)->print(Out); } return false; diff --git a/lib/Analysis/RegionPass.cpp b/lib/Analysis/RegionPass.cpp index 3c7798f2f4..d11b3323ca 100644 --- a/lib/Analysis/RegionPass.cpp +++ b/lib/Analysis/RegionPass.cpp @@ -195,8 +195,10 @@ public: bool runOnRegion(Region *R, RGPassManager &RGM) override { Out << Banner; - for (const auto &BB : R->blocks()) + for (const auto &BB : R->blocks()) { + assert(BB != nullptr && "Expecting non-null Block"); BB->print(Out); + } return false; } -- cgit v1.2.3