[llvm-commits] [llvm] r64016 - /llvm/trunk/include/llvm/Analysis/LoopInfo.h

Dan Gohman gohman at apple.com
Sat Feb 7 08:10:36 PST 2009


Author: djg
Date: Sat Feb  7 10:10:35 2009
New Revision: 64016

URL: http://llvm.org/viewvc/llvm-project?rev=64016&view=rev
Log:
Simplify some code by using blocks_begin(), blocks_end(), and
the iterator typedefs instead of handling the std::vector
directly.

Modified:
    llvm/trunk/include/llvm/Analysis/LoopInfo.h

Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=64016&r1=64015&r2=64016&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Sat Feb  7 10:10:35 2009
@@ -98,7 +98,7 @@
   /// contains - Return true if the specified basic block is in this loop
   ///
   bool contains(const BlockT *BB) const {
-    return std::find(Blocks.begin(), Blocks.end(), BB) != Blocks.end();
+    return std::find(block_begin(), block_end(), BB) != block_end();
   }
 
   /// iterator/begin/end - Return the loops contained entirely within this loop.
@@ -173,8 +173,7 @@
     std::sort(LoopBBs.begin(), LoopBBs.end());
 
     typedef GraphTraits<BlockT*> BlockTraits;
-    for (typename std::vector<BlockT*>::const_iterator BI = Blocks.begin(),
-         BE = Blocks.end(); BI != BE; ++BI)
+    for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI)
       for (typename BlockTraits::ChildIteratorType I =
           BlockTraits::child_begin(*BI), E = BlockTraits::child_end(*BI);
           I != E; ++I)
@@ -195,8 +194,7 @@
     std::sort(LoopBBs.begin(), LoopBBs.end());
 
     typedef GraphTraits<BlockT*> BlockTraits;
-    for (typename std::vector<BlockT*>::const_iterator BI = Blocks.begin(),
-         BE = Blocks.end(); BI != BE; ++BI)
+    for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI)
       for (typename BlockTraits::ChildIteratorType I =
            BlockTraits::child_begin(*BI), E = BlockTraits::child_end(*BI);
            I != E; ++I)
@@ -217,8 +215,7 @@
 
     std::vector<BlockT*> switchExitBlocks;  
 
-    for (typename std::vector<BlockT*>::const_iterator BI = Blocks.begin(),
-         BE = Blocks.end(); BI != BE; ++BI) {
+    for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI) {
 
       BlockT *current = *BI;
       switchExitBlocks.clear();
@@ -579,8 +576,7 @@
     assert (getHeader() && "Loop header is missing");
     assert (getLoopPreheader() && "Loop preheader is missing");
     assert (getLoopLatch() && "Loop latch is missing");
-    for (typename std::vector<LoopBase<BlockT>*>::const_iterator I =
-         SubLoops.begin(), E = SubLoops.end(); I != E; ++I)
+    for (iterator I = SubLoops.begin(), E = SubLoops.end(); I != E; ++I)
       (*I)->verifyLoop();
 #endif
   }





More information about the llvm-commits mailing list