]> granicus.if.org Git - clang/commitdiff
[analyzer] check for now possibly null predecessor edge.
authorTed Kremenek <kremenek@apple.com>
Thu, 27 Feb 2014 21:56:41 +0000 (21:56 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 27 Feb 2014 21:56:41 +0000 (21:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202434 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp

index 4c913a6e4a0cec729759aca2031020e6b21f8c37..66c1acd9a8678b83bd576331db54a72b47f3df26 100644 (file)
@@ -178,6 +178,9 @@ void UnreachableCodeChecker::FindUnreachableEntryPoints(const CFGBlock *CB,
 
   for (CFGBlock::const_pred_iterator I = CB->pred_begin(), E = CB->pred_end();
       I != E; ++I) {
+    if (!*I)
+      continue;
+
     if (!reachable.count((*I)->getBlockID())) {
       // If we find an unreachable predecessor, mark this block as reachable so
       // we don't report this block
@@ -219,6 +222,8 @@ bool UnreachableCodeChecker::isInvalidPath(const CFGBlock *CB,
     return false;
 
   const CFGBlock *pred = *CB->pred_begin();
+  if (!pred)
+    return false;
 
   // Get the predecessor block's terminator conditon
   const Stmt *cond = pred->getTerminatorCondition();