// Check the individual blocks.
for ( ; BI != BE; ++BI) {
BlockT *BB = *BI;
- bool HasInsideLoopSuccs = false;
- bool HasInsideLoopPreds = false;
- SmallVector<BlockT *, 2> OutsideLoopPreds;
- typedef GraphTraits<BlockT*> BlockTraits;
- for (typename BlockTraits::ChildIteratorType SI =
- BlockTraits::child_begin(BB), SE = BlockTraits::child_end(BB);
- SI != SE; ++SI)
- if (contains(*SI)) {
- HasInsideLoopSuccs = true;
- break;
- }
- assert(HasInsideLoopSuccs && "Loop block has no in-loop successors!");
+ assert(std::any_of(GraphTraits<BlockT*>::child_begin(BB),
+ GraphTraits<BlockT*>::child_end(BB),
+ [&](BlockT *B){return contains(B);}) &&
+ "Loop block has no in-loop successors!");
- typedef GraphTraits<Inverse<BlockT*> > InvBlockTraits;
- for (typename InvBlockTraits::ChildIteratorType PI =
- InvBlockTraits::child_begin(BB), PE = InvBlockTraits::child_end(BB);
- PI != PE; ++PI) {
- BlockT *N = *PI;
- if (contains(N))
- HasInsideLoopPreds = true;
- else
- OutsideLoopPreds.push_back(N);
- }
- assert(HasInsideLoopPreds && "Loop block has no in-loop predecessors!");
+ assert(std::any_of(GraphTraits<Inverse<BlockT*> >::child_begin(BB),
+ GraphTraits<Inverse<BlockT*> >::child_end(BB),
+ [&](BlockT *B){return contains(B);}) &&
+ "Loop block has no in-loop predecessors!");
+
+ SmallVector<BlockT *, 2> OutsideLoopPreds;
+ std::for_each(GraphTraits<Inverse<BlockT*> >::child_begin(BB),
+ GraphTraits<Inverse<BlockT*> >::child_end(BB),
+ [&](BlockT *B){if (!contains(B))
+ OutsideLoopPreds.push_back(B);
+ });
if (BB == getHeader()) {
assert(!OutsideLoopPreds.empty() && "Loop is unreachable!");