<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 12, 2015 at 6:12 PM, Pete Cooper <span dir="ltr"><<a href="mailto:peter_cooper@apple.com" target="_blank">peter_cooper@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: pete<br>
Date: Tue May 12 20:12:09 2015<br>
New Revision: 237224<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=237224&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=237224&view=rev</a><br>
Log:<br>
Change a loop in LoopInfo to foreach.  NFC<br>
<br>
Modified:<br>
    llvm/trunk/lib/Analysis/LoopInfo.cpp<br>
<br>
Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=237224&r1=237223&r2=237224&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=237224&r1=237223&r2=237224&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/LoopInfo.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/LoopInfo.cpp Tue May 12 20:12:09 2015<br>
@@ -65,8 +65,8 @@ bool Loop::isLoopInvariant(const Value *<br>
 /// hasLoopInvariantOperands - Return true if all the operands of the<br>
 /// specified instruction are loop invariant.<br>
 bool Loop::hasLoopInvariantOperands(const Instruction *I) const {<br>
-  for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)<br>
-    if (!isLoopInvariant(I->getOperand(i)))<br>
+  for (auto &Op : I->operands())<br>
+    if (!isLoopInvariant(Op))<br>
       return false;<br></blockquote><div><br>Could be written as:<br><br>  return std::all_of(I->operands().begin(), I->operands().end(), [&](Value *V) { return isLoopInvariant(V); );<br><br>If you like. (but the range-based-ness does make that a bit inconvenient, though std::all_of adds a little readability improvement, I think - at some point we'll just write range-based versions of algorithms like this so we don't have to pass begin/end everywhere)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
   return true;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>