1 //=- ReachableCodePathInsensitive.cpp ---------------------------*- C++ --*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements a flow-sensitive, path-insensitive analysis of
11 // determining reachable blocks within a CFG.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "clang/Analysis/Analyses/ReachableCode.h"
16 #include "clang/Lex/Preprocessor.h"
17 #include "clang/AST/Expr.h"
18 #include "clang/AST/ExprCXX.h"
19 #include "clang/AST/ExprObjC.h"
20 #include "clang/AST/StmtCXX.h"
21 #include "clang/AST/ParentMap.h"
22 #include "clang/Analysis/AnalysisContext.h"
23 #include "clang/Analysis/CFG.h"
24 #include "clang/Basic/SourceManager.h"
25 #include "llvm/ADT/BitVector.h"
26 #include "llvm/ADT/SmallVector.h"
27 
28 using namespace clang;
29 
30 //===----------------------------------------------------------------------===//
31 // Core Reachability Analysis routines.
32 //===----------------------------------------------------------------------===//
33 
34 static bool isEnumConstant(const Expr *Ex) {
35   const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Ex);
36   if (!DR)
37     return false;
38   return isa<EnumConstantDecl>(DR->getDecl());
39 }
40 
41 static bool isTrivialExpression(const Expr *Ex) {
42   Ex = Ex->IgnoreParenCasts();
43   return isa<IntegerLiteral>(Ex) || isa<StringLiteral>(Ex) ||
44          isa<CXXBoolLiteralExpr>(Ex) || isa<ObjCBoolLiteralExpr>(Ex) ||
45          isa<CharacterLiteral>(Ex) ||
46          isEnumConstant(Ex);
47 }
48 
49 static bool isTrivialDoWhile(const CFGBlock *B, const Stmt *S) {
50   // Check if the block ends with a do...while() and see if 'S' is the
51   // condition.
52   if (const Stmt *Term = B->getTerminator()) {
53     if (const DoStmt *DS = dyn_cast<DoStmt>(Term)) {
54       const Expr *Cond = DS->getCond()->IgnoreParenCasts();
55       return Cond == S && isTrivialExpression(Cond);
56     }
57   }
58   return false;
59 }
60 
61 static bool isDeadReturn(const CFGBlock *B, const Stmt *S) {
62   // Look to see if the block ends with a 'return', and see if 'S'
63   // is a substatement.  The 'return' may not be the last element in
64   // the block because of destructors.
65   for (CFGBlock::const_reverse_iterator I = B->rbegin(), E = B->rend();
66        I != E; ++I) {
67     if (Optional<CFGStmt> CS = I->getAs<CFGStmt>()) {
68       if (const ReturnStmt *RS = dyn_cast<ReturnStmt>(CS->getStmt())) {
69         if (RS == S)
70           return true;
71         if (const Expr *RE = RS->getRetValue()) {
72           RE = RE->IgnoreParenCasts();
73           if (RE == S)
74             return true;
75           ParentMap PM(const_cast<Expr*>(RE));
76           // If 'S' is in the ParentMap, it is a subexpression of
77           // the return statement.  Note also that we are restricting
78           // to looking at return statements in the same CFGBlock,
79           // so this will intentionally not catch cases where the
80           // return statement contains nested control-flow.
81           return PM.getParent(S);
82         }
83       }
84       break;
85     }
86   }
87   return false;
88 }
89 
90 static SourceLocation getTopMostMacro(SourceLocation Loc, SourceManager &SM) {
91   assert(Loc.isMacroID());
92   SourceLocation Last;
93   while (Loc.isMacroID()) {
94     Last = Loc;
95     Loc = SM.getImmediateMacroCallerLoc(Loc);
96   }
97   return Last;
98 }
99 
100 /// Returns true if the statement is expanded from a configuration macro.
101 static bool isExpandedFromConfigurationMacro(const Stmt *S,
102                                              Preprocessor &PP,
103                                              bool IgnoreYES_NO = false) {
104   // FIXME: This is not very precise.  Here we just check to see if the
105   // value comes from a macro, but we can do much better.  This is likely
106   // to be over conservative.  This logic is factored into a separate function
107   // so that we can refine it later.
108   SourceLocation L = S->getLocStart();
109   if (L.isMacroID()) {
110     if (IgnoreYES_NO) {
111       // The Objective-C constant 'YES' and 'NO'
112       // are defined as macros.  Do not treat them
113       // as configuration values.
114       SourceManager &SM = PP.getSourceManager();
115       SourceLocation TopL = getTopMostMacro(L, SM);
116       StringRef MacroName = PP.getImmediateMacroName(TopL);
117       if (MacroName == "YES" || MacroName == "NO")
118         return false;
119     }
120     return true;
121   }
122   return false;
123 }
124 
125 static bool isConfigurationValue(const ValueDecl *D, Preprocessor &PP);
126 
127 /// Returns true if the statement represents a configuration value.
128 ///
129 /// A configuration value is something usually determined at compile-time
130 /// to conditionally always execute some branch.  Such guards are for
131 /// "sometimes unreachable" code.  Such code is usually not interesting
132 /// to report as unreachable, and may mask truly unreachable code within
133 /// those blocks.
134 static bool isConfigurationValue(const Stmt *S,
135                                  Preprocessor &PP,
136                                  SourceRange *SilenceableCondVal = nullptr,
137                                  bool IncludeIntegers = true,
138                                  bool WrappedInParens = false) {
139   if (!S)
140     return false;
141 
142   // Special case looking for the sigil '()' around an integer literal.
143   if (const ParenExpr *PE = dyn_cast<ParenExpr>(S))
144     return isConfigurationValue(PE->getSubExpr(), PP, SilenceableCondVal,
145                                 IncludeIntegers, true);
146 
147   if (const Expr *Ex = dyn_cast<Expr>(S))
148     S = Ex->IgnoreParenCasts();
149 
150   switch (S->getStmtClass()) {
151     case Stmt::CallExprClass: {
152       const FunctionDecl *Callee =
153         dyn_cast_or_null<FunctionDecl>(cast<CallExpr>(S)->getCalleeDecl());
154       return Callee ? Callee->isConstexpr() : false;
155     }
156     case Stmt::DeclRefExprClass:
157       return isConfigurationValue(cast<DeclRefExpr>(S)->getDecl(), PP);
158     case Stmt::IntegerLiteralClass: {
159       const IntegerLiteral *E = cast<IntegerLiteral>(S);
160       if (IncludeIntegers) {
161         if (SilenceableCondVal && !SilenceableCondVal->getBegin().isValid())
162           *SilenceableCondVal = E->getSourceRange();
163         return WrappedInParens || isExpandedFromConfigurationMacro(E, PP);
164       }
165       return false;
166     }
167     case Stmt::MemberExprClass:
168       return isConfigurationValue(cast<MemberExpr>(S)->getMemberDecl(), PP);
169     case Stmt::ObjCBoolLiteralExprClass:
170       return isExpandedFromConfigurationMacro(S, PP, /* IgnoreYES_NO */ true);
171     case Stmt::UnaryExprOrTypeTraitExprClass:
172       return true;
173     case Stmt::BinaryOperatorClass: {
174       const BinaryOperator *B = cast<BinaryOperator>(S);
175       // Only include raw integers (not enums) as configuration
176       // values if they are used in a logical or comparison operator
177       // (not arithmetic).
178       IncludeIntegers &= (B->isLogicalOp() || B->isComparisonOp());
179       return isConfigurationValue(B->getLHS(), PP, SilenceableCondVal,
180                                   IncludeIntegers) ||
181              isConfigurationValue(B->getRHS(), PP, SilenceableCondVal,
182                                   IncludeIntegers);
183     }
184     case Stmt::UnaryOperatorClass: {
185       const UnaryOperator *UO = cast<UnaryOperator>(S);
186       if (SilenceableCondVal)
187         *SilenceableCondVal = UO->getSourceRange();
188       return UO->getOpcode() == UO_LNot &&
189              isConfigurationValue(UO->getSubExpr(), PP, SilenceableCondVal,
190                                   IncludeIntegers, WrappedInParens);
191     }
192     default:
193       return false;
194   }
195 }
196 
197 static bool isConfigurationValue(const ValueDecl *D, Preprocessor &PP) {
198   if (const EnumConstantDecl *ED = dyn_cast<EnumConstantDecl>(D))
199     return isConfigurationValue(ED->getInitExpr(), PP);
200   if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
201     // As a heuristic, treat globals as configuration values.  Note
202     // that we only will get here if Sema evaluated this
203     // condition to a constant expression, which means the global
204     // had to be declared in a way to be a truly constant value.
205     // We could generalize this to local variables, but it isn't
206     // clear if those truly represent configuration values that
207     // gate unreachable code.
208     if (!VD->hasLocalStorage())
209       return true;
210 
211     // As a heuristic, locals that have been marked 'const' explicitly
212     // can be treated as configuration values as well.
213     return VD->getType().isLocalConstQualified();
214   }
215   return false;
216 }
217 
218 /// Returns true if we should always explore all successors of a block.
219 static bool shouldTreatSuccessorsAsReachable(const CFGBlock *B,
220                                              Preprocessor &PP) {
221   if (const Stmt *Term = B->getTerminator()) {
222     if (isa<SwitchStmt>(Term))
223       return true;
224     // Specially handle '||' and '&&'.
225     if (isa<BinaryOperator>(Term)) {
226       return isConfigurationValue(Term, PP);
227     }
228   }
229 
230   const Stmt *Cond = B->getTerminatorCondition(/* stripParens */ false);
231   return isConfigurationValue(Cond, PP);
232 }
233 
234 static unsigned scanFromBlock(const CFGBlock *Start,
235                               llvm::BitVector &Reachable,
236                               Preprocessor *PP,
237                               bool IncludeSometimesUnreachableEdges) {
238   unsigned count = 0;
239 
240   // Prep work queue
241   SmallVector<const CFGBlock*, 32> WL;
242 
243   // The entry block may have already been marked reachable
244   // by the caller.
245   if (!Reachable[Start->getBlockID()]) {
246     ++count;
247     Reachable[Start->getBlockID()] = true;
248   }
249 
250   WL.push_back(Start);
251 
252   // Find the reachable blocks from 'Start'.
253   while (!WL.empty()) {
254     const CFGBlock *item = WL.pop_back_val();
255 
256     // There are cases where we want to treat all successors as reachable.
257     // The idea is that some "sometimes unreachable" code is not interesting,
258     // and that we should forge ahead and explore those branches anyway.
259     // This allows us to potentially uncover some "always unreachable" code
260     // within the "sometimes unreachable" code.
261     // Look at the successors and mark then reachable.
262     Optional<bool> TreatAllSuccessorsAsReachable;
263     if (!IncludeSometimesUnreachableEdges)
264       TreatAllSuccessorsAsReachable = false;
265 
266     for (CFGBlock::const_succ_iterator I = item->succ_begin(),
267          E = item->succ_end(); I != E; ++I) {
268       const CFGBlock *B = *I;
269       if (!B) do {
270         const CFGBlock *UB = I->getPossiblyUnreachableBlock();
271         if (!UB)
272           break;
273 
274         if (!TreatAllSuccessorsAsReachable.hasValue()) {
275           assert(PP);
276           TreatAllSuccessorsAsReachable =
277             shouldTreatSuccessorsAsReachable(item, *PP);
278         }
279 
280         if (TreatAllSuccessorsAsReachable.getValue()) {
281           B = UB;
282           break;
283         }
284       }
285       while (false);
286 
287       if (B) {
288         unsigned blockID = B->getBlockID();
289         if (!Reachable[blockID]) {
290           Reachable.set(blockID);
291           WL.push_back(B);
292           ++count;
293         }
294       }
295     }
296   }
297   return count;
298 }
299 
300 static unsigned scanMaybeReachableFromBlock(const CFGBlock *Start,
301                                             Preprocessor &PP,
302                                             llvm::BitVector &Reachable) {
303   return scanFromBlock(Start, Reachable, &PP, true);
304 }
305 
306 //===----------------------------------------------------------------------===//
307 // Dead Code Scanner.
308 //===----------------------------------------------------------------------===//
309 
310 namespace {
311   class DeadCodeScan {
312     llvm::BitVector Visited;
313     llvm::BitVector &Reachable;
314     SmallVector<const CFGBlock *, 10> WorkList;
315     Preprocessor &PP;
316 
317     typedef SmallVector<std::pair<const CFGBlock *, const Stmt *>, 12>
318     DeferredLocsTy;
319 
320     DeferredLocsTy DeferredLocs;
321 
322   public:
323     DeadCodeScan(llvm::BitVector &reachable, Preprocessor &PP)
324     : Visited(reachable.size()),
325       Reachable(reachable),
326       PP(PP) {}
327 
328     void enqueue(const CFGBlock *block);
329     unsigned scanBackwards(const CFGBlock *Start,
330     clang::reachable_code::Callback &CB);
331 
332     bool isDeadCodeRoot(const CFGBlock *Block);
333 
334     const Stmt *findDeadCode(const CFGBlock *Block);
335 
336     void reportDeadCode(const CFGBlock *B,
337                         const Stmt *S,
338                         clang::reachable_code::Callback &CB);
339   };
340 }
341 
342 void DeadCodeScan::enqueue(const CFGBlock *block) {
343   unsigned blockID = block->getBlockID();
344   if (Reachable[blockID] || Visited[blockID])
345     return;
346   Visited[blockID] = true;
347   WorkList.push_back(block);
348 }
349 
350 bool DeadCodeScan::isDeadCodeRoot(const clang::CFGBlock *Block) {
351   bool isDeadRoot = true;
352 
353   for (CFGBlock::const_pred_iterator I = Block->pred_begin(),
354        E = Block->pred_end(); I != E; ++I) {
355     if (const CFGBlock *PredBlock = *I) {
356       unsigned blockID = PredBlock->getBlockID();
357       if (Visited[blockID]) {
358         isDeadRoot = false;
359         continue;
360       }
361       if (!Reachable[blockID]) {
362         isDeadRoot = false;
363         Visited[blockID] = true;
364         WorkList.push_back(PredBlock);
365         continue;
366       }
367     }
368   }
369 
370   return isDeadRoot;
371 }
372 
373 static bool isValidDeadStmt(const Stmt *S) {
374   if (S->getLocStart().isInvalid())
375     return false;
376   if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(S))
377     return BO->getOpcode() != BO_Comma;
378   return true;
379 }
380 
381 const Stmt *DeadCodeScan::findDeadCode(const clang::CFGBlock *Block) {
382   for (CFGBlock::const_iterator I = Block->begin(), E = Block->end(); I!=E; ++I)
383     if (Optional<CFGStmt> CS = I->getAs<CFGStmt>()) {
384       const Stmt *S = CS->getStmt();
385       if (isValidDeadStmt(S))
386         return S;
387     }
388 
389   if (CFGTerminator T = Block->getTerminator()) {
390     if (!T.isTemporaryDtorsBranch()) {
391       const Stmt *S = T.getStmt();
392       if (isValidDeadStmt(S))
393         return S;
394     }
395   }
396 
397   return 0;
398 }
399 
400 static int SrcCmp(const std::pair<const CFGBlock *, const Stmt *> *p1,
401                   const std::pair<const CFGBlock *, const Stmt *> *p2) {
402   if (p1->second->getLocStart() < p2->second->getLocStart())
403     return -1;
404   if (p2->second->getLocStart() < p1->second->getLocStart())
405     return 1;
406   return 0;
407 }
408 
409 unsigned DeadCodeScan::scanBackwards(const clang::CFGBlock *Start,
410                                      clang::reachable_code::Callback &CB) {
411 
412   unsigned count = 0;
413   enqueue(Start);
414 
415   while (!WorkList.empty()) {
416     const CFGBlock *Block = WorkList.pop_back_val();
417 
418     // It is possible that this block has been marked reachable after
419     // it was enqueued.
420     if (Reachable[Block->getBlockID()])
421       continue;
422 
423     // Look for any dead code within the block.
424     const Stmt *S = findDeadCode(Block);
425 
426     if (!S) {
427       // No dead code.  Possibly an empty block.  Look at dead predecessors.
428       for (CFGBlock::const_pred_iterator I = Block->pred_begin(),
429            E = Block->pred_end(); I != E; ++I) {
430         if (const CFGBlock *predBlock = *I)
431           enqueue(predBlock);
432       }
433       continue;
434     }
435 
436     // Specially handle macro-expanded code.
437     if (S->getLocStart().isMacroID()) {
438       count += scanMaybeReachableFromBlock(Block, PP, Reachable);
439       continue;
440     }
441 
442     if (isDeadCodeRoot(Block)) {
443       reportDeadCode(Block, S, CB);
444       count += scanMaybeReachableFromBlock(Block, PP, Reachable);
445     }
446     else {
447       // Record this statement as the possibly best location in a
448       // strongly-connected component of dead code for emitting a
449       // warning.
450       DeferredLocs.push_back(std::make_pair(Block, S));
451     }
452   }
453 
454   // If we didn't find a dead root, then report the dead code with the
455   // earliest location.
456   if (!DeferredLocs.empty()) {
457     llvm::array_pod_sort(DeferredLocs.begin(), DeferredLocs.end(), SrcCmp);
458     for (DeferredLocsTy::iterator I = DeferredLocs.begin(),
459          E = DeferredLocs.end(); I != E; ++I) {
460       const CFGBlock *Block = I->first;
461       if (Reachable[Block->getBlockID()])
462         continue;
463       reportDeadCode(Block, I->second, CB);
464       count += scanMaybeReachableFromBlock(Block, PP, Reachable);
465     }
466   }
467 
468   return count;
469 }
470 
471 static SourceLocation GetUnreachableLoc(const Stmt *S,
472                                         SourceRange &R1,
473                                         SourceRange &R2) {
474   R1 = R2 = SourceRange();
475 
476   if (const Expr *Ex = dyn_cast<Expr>(S))
477     S = Ex->IgnoreParenImpCasts();
478 
479   switch (S->getStmtClass()) {
480     case Expr::BinaryOperatorClass: {
481       const BinaryOperator *BO = cast<BinaryOperator>(S);
482       return BO->getOperatorLoc();
483     }
484     case Expr::UnaryOperatorClass: {
485       const UnaryOperator *UO = cast<UnaryOperator>(S);
486       R1 = UO->getSubExpr()->getSourceRange();
487       return UO->getOperatorLoc();
488     }
489     case Expr::CompoundAssignOperatorClass: {
490       const CompoundAssignOperator *CAO = cast<CompoundAssignOperator>(S);
491       R1 = CAO->getLHS()->getSourceRange();
492       R2 = CAO->getRHS()->getSourceRange();
493       return CAO->getOperatorLoc();
494     }
495     case Expr::BinaryConditionalOperatorClass:
496     case Expr::ConditionalOperatorClass: {
497       const AbstractConditionalOperator *CO =
498       cast<AbstractConditionalOperator>(S);
499       return CO->getQuestionLoc();
500     }
501     case Expr::MemberExprClass: {
502       const MemberExpr *ME = cast<MemberExpr>(S);
503       R1 = ME->getSourceRange();
504       return ME->getMemberLoc();
505     }
506     case Expr::ArraySubscriptExprClass: {
507       const ArraySubscriptExpr *ASE = cast<ArraySubscriptExpr>(S);
508       R1 = ASE->getLHS()->getSourceRange();
509       R2 = ASE->getRHS()->getSourceRange();
510       return ASE->getRBracketLoc();
511     }
512     case Expr::CStyleCastExprClass: {
513       const CStyleCastExpr *CSC = cast<CStyleCastExpr>(S);
514       R1 = CSC->getSubExpr()->getSourceRange();
515       return CSC->getLParenLoc();
516     }
517     case Expr::CXXFunctionalCastExprClass: {
518       const CXXFunctionalCastExpr *CE = cast <CXXFunctionalCastExpr>(S);
519       R1 = CE->getSubExpr()->getSourceRange();
520       return CE->getLocStart();
521     }
522     case Stmt::CXXTryStmtClass: {
523       return cast<CXXTryStmt>(S)->getHandler(0)->getCatchLoc();
524     }
525     case Expr::ObjCBridgedCastExprClass: {
526       const ObjCBridgedCastExpr *CSC = cast<ObjCBridgedCastExpr>(S);
527       R1 = CSC->getSubExpr()->getSourceRange();
528       return CSC->getLParenLoc();
529     }
530     default: ;
531   }
532   R1 = S->getSourceRange();
533   return S->getLocStart();
534 }
535 
536 void DeadCodeScan::reportDeadCode(const CFGBlock *B,
537                                   const Stmt *S,
538                                   clang::reachable_code::Callback &CB) {
539   // Classify the unreachable code found, or suppress it in some cases.
540   reachable_code::UnreachableKind UK = reachable_code::UK_Other;
541 
542   if (isa<BreakStmt>(S)) {
543     UK = reachable_code::UK_Break;
544   }
545   else if (isTrivialDoWhile(B, S)) {
546     return;
547   }
548   else if (isDeadReturn(B, S)) {
549     UK = reachable_code::UK_Return;
550   }
551 
552   SourceRange SilenceableCondVal;
553 
554   if (UK == reachable_code::UK_Other) {
555     // Check if the dead code is part of the "loop target" of
556     // a for/for-range loop.  This is the block that contains
557     // the increment code.
558     if (const Stmt *LoopTarget = B->getLoopTarget()) {
559       SourceLocation Loc = LoopTarget->getLocStart();
560       SourceRange R1(Loc, Loc), R2;
561 
562       if (const ForStmt *FS = dyn_cast<ForStmt>(LoopTarget)) {
563         const Expr *Inc = FS->getInc();
564         Loc = Inc->getLocStart();
565         R2 = Inc->getSourceRange();
566       }
567 
568       CB.HandleUnreachable(reachable_code::UK_Loop_Increment,
569                            Loc, SourceRange(), SourceRange(Loc, Loc), R2);
570       return;
571     }
572 
573     // Check if the dead block has a predecessor whose branch has
574     // a configuration value that *could* be modified to
575     // silence the warning.
576     CFGBlock::const_pred_iterator PI = B->pred_begin();
577     if (PI != B->pred_end()) {
578       if (const CFGBlock *PredBlock = PI->getPossiblyUnreachableBlock()) {
579         const Stmt *TermCond =
580             PredBlock->getTerminatorCondition(/* strip parens */ false);
581         isConfigurationValue(TermCond, PP, &SilenceableCondVal);
582       }
583     }
584   }
585 
586   SourceRange R1, R2;
587   SourceLocation Loc = GetUnreachableLoc(S, R1, R2);
588   CB.HandleUnreachable(UK, Loc, SilenceableCondVal, R1, R2);
589 }
590 
591 //===----------------------------------------------------------------------===//
592 // Reachability APIs.
593 //===----------------------------------------------------------------------===//
594 
595 namespace clang { namespace reachable_code {
596 
597 void Callback::anchor() { }
598 
599 unsigned ScanReachableFromBlock(const CFGBlock *Start,
600                                 llvm::BitVector &Reachable) {
601   return scanFromBlock(Start, Reachable, /* SourceManager* */ 0, false);
602 }
603 
604 void FindUnreachableCode(AnalysisDeclContext &AC, Preprocessor &PP,
605                          Callback &CB) {
606 
607   CFG *cfg = AC.getCFG();
608   if (!cfg)
609     return;
610 
611   // Scan for reachable blocks from the entrance of the CFG.
612   // If there are no unreachable blocks, we're done.
613   llvm::BitVector reachable(cfg->getNumBlockIDs());
614   unsigned numReachable =
615     scanMaybeReachableFromBlock(&cfg->getEntry(), PP, reachable);
616   if (numReachable == cfg->getNumBlockIDs())
617     return;
618 
619   // If there aren't explicit EH edges, we should include the 'try' dispatch
620   // blocks as roots.
621   if (!AC.getCFGBuildOptions().AddEHEdges) {
622     for (CFG::try_block_iterator I = cfg->try_blocks_begin(),
623          E = cfg->try_blocks_end() ; I != E; ++I) {
624       numReachable += scanMaybeReachableFromBlock(*I, PP, reachable);
625     }
626     if (numReachable == cfg->getNumBlockIDs())
627       return;
628   }
629 
630   // There are some unreachable blocks.  We need to find the root blocks that
631   // contain code that should be considered unreachable.
632   for (CFG::iterator I = cfg->begin(), E = cfg->end(); I != E; ++I) {
633     const CFGBlock *block = *I;
634     // A block may have been marked reachable during this loop.
635     if (reachable[block->getBlockID()])
636       continue;
637 
638     DeadCodeScan DS(reachable, PP);
639     numReachable += DS.scanBackwards(block, CB);
640 
641     if (numReachable == cfg->getNumBlockIDs())
642       return;
643   }
644 }
645 
646 }} // end namespace clang::reachable_code
647