[-Wunreachable-code] handle cases where a dead 'return' may have a valid predecessor.
Fies PR19040.
llvm-svn: 202892
diff --git a/clang/lib/Analysis/ReachableCode.cpp b/clang/lib/Analysis/ReachableCode.cpp
index 4a19280..b0e9250 100644
--- a/clang/lib/Analysis/ReachableCode.cpp
+++ b/clang/lib/Analysis/ReachableCode.cpp
@@ -263,6 +263,11 @@
}
static bool bodyEndsWithNoReturn(const CFGBlock::AdjacentBlock &AB) {
+ // If the predecessor is a normal CFG edge, then by definition
+ // the predecessor did not end with a 'noreturn'.
+ if (AB.getReachableBlock())
+ return false;
+
const CFGBlock *Pred = AB.getPossiblyUnreachableBlock();
assert(!AB.isReachable() && Pred);
return bodyEndsWithNoReturn(Pred);