[PATCH] D19964: [scan-build] fix warnings emiited on LLVM Analysis code base

Apelete Seketeli via llvm-commits llvm-commits at lists.llvm.org
Thu May 5 04:49:18 PDT 2016


apelete created this revision.
apelete added reviewers: silviu.baranga, atrick, hfinkel.
apelete added a subscriber: llvm-commits.
Herald added a subscriber: mzolotukhin.

Fix "Logic error" warnings of the type "Called C++ object pointer is
null" reported by Clang Static Analyzer on the following files:

- lib/Analysis/ScalarEvolution.cpp,
- lib/Analysis/LoopInfo.cpp.

Signed-off-by: Apelete Seketeli <apelete at seketeli.net>

http://reviews.llvm.org/D19964

Files:
  lib/Analysis/LoopInfo.cpp
  lib/Analysis/ScalarEvolution.cpp

Index: lib/Analysis/ScalarEvolution.cpp
===================================================================
--- lib/Analysis/ScalarEvolution.cpp
+++ lib/Analysis/ScalarEvolution.cpp
@@ -5554,6 +5554,8 @@
   if (NumExits == 1)
     return;
 
+  assert(ENT && "ExitNotTakenExtras array is NULL, cannot further compute exits");
+
   auto &Exits = ExitNotTaken.ExtraInfo->Exits;
 
   // Handle the rare case of multiple computable exits.
Index: lib/Analysis/LoopInfo.cpp
===================================================================
--- lib/Analysis/LoopInfo.cpp
+++ lib/Analysis/LoopInfo.cpp
@@ -512,11 +512,14 @@
 /// For subloop blocks, simply update SubloopParents and return NULL.
 Loop *UnloopUpdater::getNearestLoop(BasicBlock *BB, Loop *BBLoop) {
 
+  assert(Unloop && "Unloop cannot be NULL");
+
   // Initially for blocks directly contained by Unloop, NearLoop == Unloop and
   // is considered uninitialized.
   Loop *NearLoop = BBLoop;
 
   Loop *Subloop = nullptr;
+  assert(Unloop && "does not contain any loop");
   if (NearLoop != Unloop && Unloop->contains(NearLoop)) {
     Subloop = NearLoop;
     // Find the subloop ancestor that is directly contained within Unloop.
@@ -545,6 +548,7 @@
       assert((FoundIB || !DFS.hasPostorder(*I)) && "should have seen IB");
       FoundIB = true;
     }
+    assert(Unloop && "does not contain any loop");
     if (L != Unloop && Unloop->contains(L)) {
       // Successor is in a subloop.
       if (Subloop)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19964.56266.patch
Type: text/x-patch
Size: 1472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160505/1b33cc24/attachment.bin>


More information about the llvm-commits mailing list