[PATCH] CodeGenPrep: rewrite a few loops in C++11 style

Ramkumar Ramachandra artagnon at gmail.com
Wed Jan 7 11:20:35 PST 2015


Hi qcolombet, craig.topper,

I wanted to add some code to CodeGenPrep, but I thought I should get
these nits out of the way first.

http://reviews.llvm.org/D6868

Files:
  lib/CodeGen/CodeGenPrepare.cpp

Index: lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- lib/CodeGen/CodeGenPrepare.cpp
+++ lib/CodeGen/CodeGenPrepare.cpp
@@ -218,7 +218,7 @@
   if (!OptSize && TLI && TLI->isSlowDivBypassed()) {
     const DenseMap<unsigned int, unsigned int> &BypassWidths =
        TLI->getBypassSlowDivWidths();
-    for (Function::iterator I = F.begin(); I != F.end(); I++)
+    for (Function::iterator I : F)
       EverMadeChange |= bypassSlowDivision(F, I, BypassWidths);
   }
 
@@ -261,7 +261,7 @@
   if (!DisableBranchOpts) {
     MadeChange = false;
     SmallPtrSet<BasicBlock*, 8> WorkList;
-    for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
+    for (Function::iterator BB : F) {
       SmallVector<BasicBlock*, 2> Successors(succ_begin(BB), succ_end(BB));
       MadeChange |= ConstantFoldTerminator(BB, true);
       if (!MadeChange) continue;
@@ -4297,7 +4297,7 @@
 // find a node corresponding to the value.
 bool CodeGenPrepare::PlaceDbgValues(Function &F) {
   bool MadeChange = false;
-  for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
+  for (Function::iterator I : F) {
     Instruction *PrevNonDbgInst = nullptr;
     for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE;) {
       Instruction *Insn = BI; ++BI;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6868.17867.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150107/8eacd668/attachment.bin>


More information about the llvm-commits mailing list