From: Ted Kremenek Date: Thu, 27 Feb 2014 21:56:41 +0000 (+0000) Subject: [analyzer] check for now possibly null predecessor edge. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d4ba7a271dee92a4f5a2985f94aefb9c38dd238b;p=clang [analyzer] check for now possibly null predecessor edge. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202434 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index 4c913a6e4a..66c1acd9a8 100644 --- a/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -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();