From a849604d0397bfb9b3ec8f3aaba44f810da176ef Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 15 Mar 2014 10:20:49 +0000 Subject: [PATCH] Remove dead functions from unreachable code analysis. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204004 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ReachableCode.cpp | 44 ---------------------------------- 1 file changed, 44 deletions(-) diff --git a/lib/Analysis/ReachableCode.cpp b/lib/Analysis/ReachableCode.cpp index 71d41bb283..463883f826 100644 --- a/lib/Analysis/ReachableCode.cpp +++ b/lib/Analysis/ReachableCode.cpp @@ -30,50 +30,6 @@ using namespace clang; // Core Reachability Analysis routines. //===----------------------------------------------------------------------===// -static bool bodyEndsWithNoReturn(const CFGBlock *B) { - for (CFGBlock::const_reverse_iterator I = B->rbegin(), E = B->rend(); - I != E; ++I) { - if (Optional CS = I->getAs()) { - const Stmt *S = CS->getStmt(); - if (const ExprWithCleanups *EWC = dyn_cast(S)) - S = EWC->getSubExpr(); - if (const CallExpr *CE = dyn_cast(S)) { - QualType CalleeType = CE->getCallee()->getType(); - if (getFunctionExtInfo(*CalleeType).getNoReturn()) - return true; - } - break; - } - } - return false; -} - -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); -} - -static bool isBreakPrecededByNoReturn(const CFGBlock *B, const Stmt *S, - reachable_code::UnreachableKind &UK) { - if (!isa(S)) - return false; - - UK = reachable_code::UK_Break; - - if (B->pred_empty()) - return false; - - assert(B->empty()); - assert(B->pred_size() == 1); - return bodyEndsWithNoReturn(*B->pred_begin()); -} - static bool isEnumConstant(const Expr *Ex) { const DeclRefExpr *DR = dyn_cast(Ex); if (!DR) -- 2.40.0