From: Mike Stump Date: Thu, 14 Jan 2010 02:45:29 +0000 (+0000) Subject: Don't assume a random access iterator, instead just use CFG::iterator. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b64cc58087b0874ed96ac76ebcf8d9006bd63282;p=clang Don't assume a random access iterator, instead just use CFG::iterator. Thanks Ted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93413 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 40c3e754ad..75fe7fd00f 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1344,9 +1344,9 @@ void Sema::CheckUnreachable(AnalysisContext &AC) { // Mark all live things first. MarkLive(&cfg->getEntry(), live); - for (unsigned i = 0; i < cfg->getNumBlockIDs(); ++i) { - if (!live[i]) { - CFGBlock &b = *(cfg->begin()[i]); + for (CFG::iterator I = cfg->begin(), E = cfg->end(); I != E; ++I) { + CFGBlock &b = **I; + if (!live[b.getBlockID()]) { if (!b.empty()) Diag(b[0].getStmt()->getLocStart(), diag::warn_unreachable); // Avoid excessive errors by marking everything reachable from here