<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 11, 2015 at 6:10 AM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: aaronballman<br>
Date: Mon May 11 08:10:17 2015<br>
New Revision: 236990<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=236990&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=236990&view=rev</a><br>
Log:<br>
Replacing a range-based for loop with an old-style for loop. This code was previously causing a warning with MSVC about a compiler-generated local variable because TargetRegistry::begin() and end() are static member functions. NFC.<br></blockquote><div><br>(usual response from me: I'm not sure this really improves the readability of the code, could we just disable the MSVC warning instead?<br><br>Possible alternative: TargetRegistry should probably just be a namespace, not a class (it's just a collection of static functions, right?) and possibly have some kind of range accessor that returns an object: "for (const auto &Target : TargetRegistry::targets())" or the like)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/unittests/Support/TargetRegistry.cpp<br>
<br>
Modified: llvm/trunk/unittests/Support/TargetRegistry.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TargetRegistry.cpp?rev=236990&r1=236989&r2=236990&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TargetRegistry.cpp?rev=236990&r1=236989&r2=236990&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/Support/TargetRegistry.cpp (original)<br>
+++ llvm/trunk/unittests/Support/TargetRegistry.cpp Mon May 11 08:10:17 2015<br>
@@ -23,8 +23,9 @@ TEST(TargetRegistry, TargetHasArchType)<br>
   llvm::InitializeAllTargetInfos();<br>
<br>
   llvm::TargetRegistry RegistryRoot;<br>
-  for (const auto &Target : RegistryRoot) {<br>
-    StringRef Name = Target.getName();<br>
+  for (auto &I = TargetRegistry::begin(), &E = TargetRegistry::end();<br>
+       I != E; ++I) {<br>
+    StringRef Name = I->getName();<br>
     // There is really no way (at present) to ask a Target whether it targets<br>
     // a specific architecture, because the logic for that is buried in a<br>
     // predicate.<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>