[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges.
[oota-llvm.git] / lib / Transforms / Scalar / SampleProfile.cpp
index 73c97ffeef4f98fdf65558665f589fcaa8eb8b18..8e3583a1237854f7c05a31d33a46d846b872aa9b 100644 (file)
@@ -865,8 +865,7 @@ void SampleFunctionProfile::buildEdges(Function &F) {
     SmallPtrSet<BasicBlock *, 16> Visited;
     if (!Predecessors[B1].empty())
       llvm_unreachable("Found a stale predecessors list in a basic block.");
-    for (pred_iterator PI = pred_begin(B1), PE = pred_end(B1); PI != PE; ++PI) {
-      BasicBlock *B2 = *PI;
+    for (BasicBlock *B2 : predecessors(B1)) {
       if (Visited.insert(B2))
         Predecessors[B1].push_back(B2);
     }
@@ -875,8 +874,7 @@ void SampleFunctionProfile::buildEdges(Function &F) {
     Visited.clear();
     if (!Successors[B1].empty())
       llvm_unreachable("Found a stale successors list in a basic block.");
-    for (succ_iterator SI = succ_begin(B1), SE = succ_end(B1); SI != SE; ++SI) {
-      BasicBlock *B2 = *SI;
+    for (BasicBlock *B2 : successors(B1)) {
       if (Visited.insert(B2))
         Successors[B1].push_back(B2);
     }