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 if (const Expr *Ex = dyn_cast<Expr>(S)) 143 S = Ex->IgnoreCasts(); 144 145 // Special case looking for the sigil '()' around an integer literal. 146 if (const ParenExpr *PE = dyn_cast<ParenExpr>(S)) 147 if (!PE->getLocStart().isMacroID()) 148 return isConfigurationValue(PE->getSubExpr(), PP, SilenceableCondVal, 149 IncludeIntegers, true); 150 151 if (const Expr *Ex = dyn_cast<Expr>(S)) 152 S = Ex->IgnoreCasts(); 153 154 bool IgnoreYES_NO = false; 155 156 switch (S->getStmtClass()) { 157 case Stmt::CallExprClass: { 158 const FunctionDecl *Callee = 159 dyn_cast_or_null<FunctionDecl>(cast<CallExpr>(S)->getCalleeDecl()); 160 return Callee ? Callee->isConstexpr() : false; 161 } 162 case Stmt::DeclRefExprClass: 163 return isConfigurationValue(cast<DeclRefExpr>(S)->getDecl(), PP); 164 case Stmt::ObjCBoolLiteralExprClass: 165 IgnoreYES_NO = true; 166 // Fallthrough. 167 case Stmt::CXXBoolLiteralExprClass: 168 case Stmt::IntegerLiteralClass: { 169 const Expr *E = cast<Expr>(S); 170 if (IncludeIntegers) { 171 if (SilenceableCondVal && !SilenceableCondVal->getBegin().isValid()) 172 *SilenceableCondVal = E->getSourceRange(); 173 return WrappedInParens || isExpandedFromConfigurationMacro(E, PP, IgnoreYES_NO); 174 } 175 return false; 176 } 177 case Stmt::MemberExprClass: 178 return isConfigurationValue(cast<MemberExpr>(S)->getMemberDecl(), PP); 179 case Stmt::UnaryExprOrTypeTraitExprClass: 180 return true; 181 case Stmt::BinaryOperatorClass: { 182 const BinaryOperator *B = cast<BinaryOperator>(S); 183 // Only include raw integers (not enums) as configuration 184 // values if they are used in a logical or comparison operator 185 // (not arithmetic). 186 IncludeIntegers &= (B->isLogicalOp() || B->isComparisonOp()); 187 return isConfigurationValue(B->getLHS(), PP, SilenceableCondVal, 188 IncludeIntegers) || 189 isConfigurationValue(B->getRHS(), PP, SilenceableCondVal, 190 IncludeIntegers); 191 } 192 case Stmt::UnaryOperatorClass: { 193 const UnaryOperator *UO = cast<UnaryOperator>(S); 194 if (SilenceableCondVal) 195 *SilenceableCondVal = UO->getSourceRange(); 196 return UO->getOpcode() == UO_LNot && 197 isConfigurationValue(UO->getSubExpr(), PP, SilenceableCondVal, 198 IncludeIntegers, WrappedInParens); 199 } 200 default: 201 return false; 202 } 203 } 204 205 static bool isConfigurationValue(const ValueDecl *D, Preprocessor &PP) { 206 if (const EnumConstantDecl *ED = dyn_cast<EnumConstantDecl>(D)) 207 return isConfigurationValue(ED->getInitExpr(), PP); 208 if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { 209 // As a heuristic, treat globals as configuration values. Note 210 // that we only will get here if Sema evaluated this 211 // condition to a constant expression, which means the global 212 // had to be declared in a way to be a truly constant value. 213 // We could generalize this to local variables, but it isn't 214 // clear if those truly represent configuration values that 215 // gate unreachable code. 216 if (!VD->hasLocalStorage()) 217 return true; 218 219 // As a heuristic, locals that have been marked 'const' explicitly 220 // can be treated as configuration values as well. 221 return VD->getType().isLocalConstQualified(); 222 } 223 return false; 224 } 225 226 /// Returns true if we should always explore all successors of a block. 227 static bool shouldTreatSuccessorsAsReachable(const CFGBlock *B, 228 Preprocessor &PP) { 229 if (const Stmt *Term = B->getTerminator()) { 230 if (isa<SwitchStmt>(Term)) 231 return true; 232 // Specially handle '||' and '&&'. 233 if (isa<BinaryOperator>(Term)) { 234 return isConfigurationValue(Term, PP); 235 } 236 } 237 238 const Stmt *Cond = B->getTerminatorCondition(/* stripParens */ false); 239 return isConfigurationValue(Cond, PP); 240 } 241 242 static unsigned scanFromBlock(const CFGBlock *Start, 243 llvm::BitVector &Reachable, 244 Preprocessor *PP, 245 bool IncludeSometimesUnreachableEdges) { 246 unsigned count = 0; 247 248 // Prep work queue 249 SmallVector<const CFGBlock*, 32> WL; 250 251 // The entry block may have already been marked reachable 252 // by the caller. 253 if (!Reachable[Start->getBlockID()]) { 254 ++count; 255 Reachable[Start->getBlockID()] = true; 256 } 257 258 WL.push_back(Start); 259 260 // Find the reachable blocks from 'Start'. 261 while (!WL.empty()) { 262 const CFGBlock *item = WL.pop_back_val(); 263 264 // There are cases where we want to treat all successors as reachable. 265 // The idea is that some "sometimes unreachable" code is not interesting, 266 // and that we should forge ahead and explore those branches anyway. 267 // This allows us to potentially uncover some "always unreachable" code 268 // within the "sometimes unreachable" code. 269 // Look at the successors and mark then reachable. 270 Optional<bool> TreatAllSuccessorsAsReachable; 271 if (!IncludeSometimesUnreachableEdges) 272 TreatAllSuccessorsAsReachable = false; 273 274 for (CFGBlock::const_succ_iterator I = item->succ_begin(), 275 E = item->succ_end(); I != E; ++I) { 276 const CFGBlock *B = *I; 277 if (!B) do { 278 const CFGBlock *UB = I->getPossiblyUnreachableBlock(); 279 if (!UB) 280 break; 281 282 if (!TreatAllSuccessorsAsReachable.hasValue()) { 283 assert(PP); 284 TreatAllSuccessorsAsReachable = 285 shouldTreatSuccessorsAsReachable(item, *PP); 286 } 287 288 if (TreatAllSuccessorsAsReachable.getValue()) { 289 B = UB; 290 break; 291 } 292 } 293 while (false); 294 295 if (B) { 296 unsigned blockID = B->getBlockID(); 297 if (!Reachable[blockID]) { 298 Reachable.set(blockID); 299 WL.push_back(B); 300 ++count; 301 } 302 } 303 } 304 } 305 return count; 306 } 307 308 static unsigned scanMaybeReachableFromBlock(const CFGBlock *Start, 309 Preprocessor &PP, 310 llvm::BitVector &Reachable) { 311 return scanFromBlock(Start, Reachable, &PP, true); 312 } 313 314 //===----------------------------------------------------------------------===// 315 // Dead Code Scanner. 316 //===----------------------------------------------------------------------===// 317 318 namespace { 319 class DeadCodeScan { 320 llvm::BitVector Visited; 321 llvm::BitVector &Reachable; 322 SmallVector<const CFGBlock *, 10> WorkList; 323 Preprocessor &PP; 324 325 typedef SmallVector<std::pair<const CFGBlock *, const Stmt *>, 12> 326 DeferredLocsTy; 327 328 DeferredLocsTy DeferredLocs; 329 330 public: 331 DeadCodeScan(llvm::BitVector &reachable, Preprocessor &PP) 332 : Visited(reachable.size()), 333 Reachable(reachable), 334 PP(PP) {} 335 336 void enqueue(const CFGBlock *block); 337 unsigned scanBackwards(const CFGBlock *Start, 338 clang::reachable_code::Callback &CB); 339 340 bool isDeadCodeRoot(const CFGBlock *Block); 341 342 const Stmt *findDeadCode(const CFGBlock *Block); 343 344 void reportDeadCode(const CFGBlock *B, 345 const Stmt *S, 346 clang::reachable_code::Callback &CB); 347 }; 348 } 349 350 void DeadCodeScan::enqueue(const CFGBlock *block) { 351 unsigned blockID = block->getBlockID(); 352 if (Reachable[blockID] || Visited[blockID]) 353 return; 354 Visited[blockID] = true; 355 WorkList.push_back(block); 356 } 357 358 bool DeadCodeScan::isDeadCodeRoot(const clang::CFGBlock *Block) { 359 bool isDeadRoot = true; 360 361 for (CFGBlock::const_pred_iterator I = Block->pred_begin(), 362 E = Block->pred_end(); I != E; ++I) { 363 if (const CFGBlock *PredBlock = *I) { 364 unsigned blockID = PredBlock->getBlockID(); 365 if (Visited[blockID]) { 366 isDeadRoot = false; 367 continue; 368 } 369 if (!Reachable[blockID]) { 370 isDeadRoot = false; 371 Visited[blockID] = true; 372 WorkList.push_back(PredBlock); 373 continue; 374 } 375 } 376 } 377 378 return isDeadRoot; 379 } 380 381 static bool isValidDeadStmt(const Stmt *S) { 382 if (S->getLocStart().isInvalid()) 383 return false; 384 if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(S)) 385 return BO->getOpcode() != BO_Comma; 386 return true; 387 } 388 389 const Stmt *DeadCodeScan::findDeadCode(const clang::CFGBlock *Block) { 390 for (CFGBlock::const_iterator I = Block->begin(), E = Block->end(); I!=E; ++I) 391 if (Optional<CFGStmt> CS = I->getAs<CFGStmt>()) { 392 const Stmt *S = CS->getStmt(); 393 if (isValidDeadStmt(S)) 394 return S; 395 } 396 397 if (CFGTerminator T = Block->getTerminator()) { 398 if (!T.isTemporaryDtorsBranch()) { 399 const Stmt *S = T.getStmt(); 400 if (isValidDeadStmt(S)) 401 return S; 402 } 403 } 404 405 return 0; 406 } 407 408 static int SrcCmp(const std::pair<const CFGBlock *, const Stmt *> *p1, 409 const std::pair<const CFGBlock *, const Stmt *> *p2) { 410 if (p1->second->getLocStart() < p2->second->getLocStart()) 411 return -1; 412 if (p2->second->getLocStart() < p1->second->getLocStart()) 413 return 1; 414 return 0; 415 } 416 417 unsigned DeadCodeScan::scanBackwards(const clang::CFGBlock *Start, 418 clang::reachable_code::Callback &CB) { 419 420 unsigned count = 0; 421 enqueue(Start); 422 423 while (!WorkList.empty()) { 424 const CFGBlock *Block = WorkList.pop_back_val(); 425 426 // It is possible that this block has been marked reachable after 427 // it was enqueued. 428 if (Reachable[Block->getBlockID()]) 429 continue; 430 431 // Look for any dead code within the block. 432 const Stmt *S = findDeadCode(Block); 433 434 if (!S) { 435 // No dead code. Possibly an empty block. Look at dead predecessors. 436 for (CFGBlock::const_pred_iterator I = Block->pred_begin(), 437 E = Block->pred_end(); I != E; ++I) { 438 if (const CFGBlock *predBlock = *I) 439 enqueue(predBlock); 440 } 441 continue; 442 } 443 444 // Specially handle macro-expanded code. 445 if (S->getLocStart().isMacroID()) { 446 count += scanMaybeReachableFromBlock(Block, PP, Reachable); 447 continue; 448 } 449 450 if (isDeadCodeRoot(Block)) { 451 reportDeadCode(Block, S, CB); 452 count += scanMaybeReachableFromBlock(Block, PP, Reachable); 453 } 454 else { 455 // Record this statement as the possibly best location in a 456 // strongly-connected component of dead code for emitting a 457 // warning. 458 DeferredLocs.push_back(std::make_pair(Block, S)); 459 } 460 } 461 462 // If we didn't find a dead root, then report the dead code with the 463 // earliest location. 464 if (!DeferredLocs.empty()) { 465 llvm::array_pod_sort(DeferredLocs.begin(), DeferredLocs.end(), SrcCmp); 466 for (DeferredLocsTy::iterator I = DeferredLocs.begin(), 467 E = DeferredLocs.end(); I != E; ++I) { 468 const CFGBlock *Block = I->first; 469 if (Reachable[Block->getBlockID()]) 470 continue; 471 reportDeadCode(Block, I->second, CB); 472 count += scanMaybeReachableFromBlock(Block, PP, Reachable); 473 } 474 } 475 476 return count; 477 } 478 479 static SourceLocation GetUnreachableLoc(const Stmt *S, 480 SourceRange &R1, 481 SourceRange &R2) { 482 R1 = R2 = SourceRange(); 483 484 if (const Expr *Ex = dyn_cast<Expr>(S)) 485 S = Ex->IgnoreParenImpCasts(); 486 487 switch (S->getStmtClass()) { 488 case Expr::BinaryOperatorClass: { 489 const BinaryOperator *BO = cast<BinaryOperator>(S); 490 return BO->getOperatorLoc(); 491 } 492 case Expr::UnaryOperatorClass: { 493 const UnaryOperator *UO = cast<UnaryOperator>(S); 494 R1 = UO->getSubExpr()->getSourceRange(); 495 return UO->getOperatorLoc(); 496 } 497 case Expr::CompoundAssignOperatorClass: { 498 const CompoundAssignOperator *CAO = cast<CompoundAssignOperator>(S); 499 R1 = CAO->getLHS()->getSourceRange(); 500 R2 = CAO->getRHS()->getSourceRange(); 501 return CAO->getOperatorLoc(); 502 } 503 case Expr::BinaryConditionalOperatorClass: 504 case Expr::ConditionalOperatorClass: { 505 const AbstractConditionalOperator *CO = 506 cast<AbstractConditionalOperator>(S); 507 return CO->getQuestionLoc(); 508 } 509 case Expr::MemberExprClass: { 510 const MemberExpr *ME = cast<MemberExpr>(S); 511 R1 = ME->getSourceRange(); 512 return ME->getMemberLoc(); 513 } 514 case Expr::ArraySubscriptExprClass: { 515 const ArraySubscriptExpr *ASE = cast<ArraySubscriptExpr>(S); 516 R1 = ASE->getLHS()->getSourceRange(); 517 R2 = ASE->getRHS()->getSourceRange(); 518 return ASE->getRBracketLoc(); 519 } 520 case Expr::CStyleCastExprClass: { 521 const CStyleCastExpr *CSC = cast<CStyleCastExpr>(S); 522 R1 = CSC->getSubExpr()->getSourceRange(); 523 return CSC->getLParenLoc(); 524 } 525 case Expr::CXXFunctionalCastExprClass: { 526 const CXXFunctionalCastExpr *CE = cast <CXXFunctionalCastExpr>(S); 527 R1 = CE->getSubExpr()->getSourceRange(); 528 return CE->getLocStart(); 529 } 530 case Stmt::CXXTryStmtClass: { 531 return cast<CXXTryStmt>(S)->getHandler(0)->getCatchLoc(); 532 } 533 case Expr::ObjCBridgedCastExprClass: { 534 const ObjCBridgedCastExpr *CSC = cast<ObjCBridgedCastExpr>(S); 535 R1 = CSC->getSubExpr()->getSourceRange(); 536 return CSC->getLParenLoc(); 537 } 538 default: ; 539 } 540 R1 = S->getSourceRange(); 541 return S->getLocStart(); 542 } 543 544 void DeadCodeScan::reportDeadCode(const CFGBlock *B, 545 const Stmt *S, 546 clang::reachable_code::Callback &CB) { 547 // Classify the unreachable code found, or suppress it in some cases. 548 reachable_code::UnreachableKind UK = reachable_code::UK_Other; 549 550 if (isa<BreakStmt>(S)) { 551 UK = reachable_code::UK_Break; 552 } 553 else if (isTrivialDoWhile(B, S)) { 554 return; 555 } 556 else if (isDeadReturn(B, S)) { 557 UK = reachable_code::UK_Return; 558 } 559 560 SourceRange SilenceableCondVal; 561 562 if (UK == reachable_code::UK_Other) { 563 // Check if the dead code is part of the "loop target" of 564 // a for/for-range loop. This is the block that contains 565 // the increment code. 566 if (const Stmt *LoopTarget = B->getLoopTarget()) { 567 SourceLocation Loc = LoopTarget->getLocStart(); 568 SourceRange R1(Loc, Loc), R2; 569 570 if (const ForStmt *FS = dyn_cast<ForStmt>(LoopTarget)) { 571 const Expr *Inc = FS->getInc(); 572 Loc = Inc->getLocStart(); 573 R2 = Inc->getSourceRange(); 574 } 575 576 CB.HandleUnreachable(reachable_code::UK_Loop_Increment, 577 Loc, SourceRange(), SourceRange(Loc, Loc), R2); 578 return; 579 } 580 581 // Check if the dead block has a predecessor whose branch has 582 // a configuration value that *could* be modified to 583 // silence the warning. 584 CFGBlock::const_pred_iterator PI = B->pred_begin(); 585 if (PI != B->pred_end()) { 586 if (const CFGBlock *PredBlock = PI->getPossiblyUnreachableBlock()) { 587 const Stmt *TermCond = 588 PredBlock->getTerminatorCondition(/* strip parens */ false); 589 isConfigurationValue(TermCond, PP, &SilenceableCondVal); 590 } 591 } 592 } 593 594 SourceRange R1, R2; 595 SourceLocation Loc = GetUnreachableLoc(S, R1, R2); 596 CB.HandleUnreachable(UK, Loc, SilenceableCondVal, R1, R2); 597 } 598 599 //===----------------------------------------------------------------------===// 600 // Reachability APIs. 601 //===----------------------------------------------------------------------===// 602 603 namespace clang { namespace reachable_code { 604 605 void Callback::anchor() { } 606 607 unsigned ScanReachableFromBlock(const CFGBlock *Start, 608 llvm::BitVector &Reachable) { 609 return scanFromBlock(Start, Reachable, /* SourceManager* */ 0, false); 610 } 611 612 void FindUnreachableCode(AnalysisDeclContext &AC, Preprocessor &PP, 613 Callback &CB) { 614 615 CFG *cfg = AC.getCFG(); 616 if (!cfg) 617 return; 618 619 // Scan for reachable blocks from the entrance of the CFG. 620 // If there are no unreachable blocks, we're done. 621 llvm::BitVector reachable(cfg->getNumBlockIDs()); 622 unsigned numReachable = 623 scanMaybeReachableFromBlock(&cfg->getEntry(), PP, reachable); 624 if (numReachable == cfg->getNumBlockIDs()) 625 return; 626 627 // If there aren't explicit EH edges, we should include the 'try' dispatch 628 // blocks as roots. 629 if (!AC.getCFGBuildOptions().AddEHEdges) { 630 for (CFG::try_block_iterator I = cfg->try_blocks_begin(), 631 E = cfg->try_blocks_end() ; I != E; ++I) { 632 numReachable += scanMaybeReachableFromBlock(*I, PP, reachable); 633 } 634 if (numReachable == cfg->getNumBlockIDs()) 635 return; 636 } 637 638 // There are some unreachable blocks. We need to find the root blocks that 639 // contain code that should be considered unreachable. 640 for (CFG::iterator I = cfg->begin(), E = cfg->end(); I != E; ++I) { 641 const CFGBlock *block = *I; 642 // A block may have been marked reachable during this loop. 643 if (reachable[block->getBlockID()]) 644 continue; 645 646 DeadCodeScan DS(reachable, PP); 647 numReachable += DS.scanBackwards(block, CB); 648 649 if (numReachable == cfg->getNumBlockIDs()) 650 return; 651 } 652 } 653 654 }} // end namespace clang::reachable_code 655