Author: Nico Weber Date: 2021-10-10T15:15:37-04:00 New Revision: 62abc1842bc8b4860f9f7c1165164740fccef64e
URL: https://github.com/llvm/llvm-project/commit/62abc1842bc8b4860f9f7c1165164740fccef64e DIFF: https://github.com/llvm/llvm-project/commit/62abc1842bc8b4860f9f7c1165164740fccef64e.diff LOG: clang: Add range-based CFG::try_blocks() ..and use it. No behavior change. Added: Modified: clang/include/clang/Analysis/CFG.h clang/lib/Analysis/ReachableCode.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Analysis/CFG.h b/clang/include/clang/Analysis/CFG.h index 9e32eb8e066a..f9223fe58a27 100644 --- a/clang/include/clang/Analysis/CFG.h +++ b/clang/include/clang/Analysis/CFG.h @@ -1337,6 +1337,7 @@ class CFG { const CFGBlock * getIndirectGotoBlock() const { return IndirectGotoBlock; } using try_block_iterator = std::vector<const CFGBlock *>::const_iterator; + using try_block_range = llvm::iterator_range<try_block_iterator>; try_block_iterator try_blocks_begin() const { return TryDispatchBlocks.begin(); @@ -1346,6 +1347,10 @@ class CFG { return TryDispatchBlocks.end(); } + try_block_range try_blocks() const { + return try_block_range(try_blocks_begin(), try_blocks_end()); + } + void addTryDispatchBlock(const CFGBlock *block) { TryDispatchBlocks.push_back(block); } diff --git a/clang/lib/Analysis/ReachableCode.cpp b/clang/lib/Analysis/ReachableCode.cpp index 9abcf20eacba..be4ab0be373e 100644 --- a/clang/lib/Analysis/ReachableCode.cpp +++ b/clang/lib/Analysis/ReachableCode.cpp @@ -694,10 +694,8 @@ void FindUnreachableCode(AnalysisDeclContext &AC, Preprocessor &PP, // If there aren't explicit EH edges, we should include the 'try' dispatch // blocks as roots. if (!AC.getCFGBuildOptions().AddEHEdges) { - for (CFG::try_block_iterator I = cfg->try_blocks_begin(), - E = cfg->try_blocks_end() ; I != E; ++I) { - numReachable += scanMaybeReachableFromBlock(*I, PP, reachable); - } + for (const CFGBlock *B : cfg->try_blocks()) + numReachable += scanMaybeReachableFromBlock(B, PP, reachable); if (numReachable == cfg->getNumBlockIDs()) return; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits