<div dir="ltr">Thanks!</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 25, 2015 at 11:51 AM, Douglas Katzman <span dir="ltr"><<a href="mailto:dougk@google.com" target="_blank">dougk@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dougk<br>
Date: Thu Jun 25 13:51:37 2015<br>
New Revision: 240674<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D240674-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=t4c57bn1tDTH0uH4hxsCVsOlRsCp9ovqnt_Ct-eSByo&s=jV3h8Nucoljnn7igEhNtIG5e6cUYMtG72e2tVS19k7k&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=240674&view=rev</a><br>
Log:<br>
Use more range-based for loops<br>
<br>
Differential Revision: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10738&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=t4c57bn1tDTH0uH4hxsCVsOlRsCp9ovqnt_Ct-eSByo&s=F-E0bQ_0kZonifCiwMK6C9VWl9-2-kHQt3fzHAAvjx0&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D10738</a><br>
<br>
Modified:<br>
    cfe/trunk/lib/Driver/Driver.cpp<br>
    cfe/trunk/lib/Driver/ToolChains.cpp<br>
    cfe/trunk/lib/Driver/Tools.cpp<br>
<br>
Modified: cfe/trunk/lib/Driver/Driver.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Driver_Driver.cpp-3Frev-3D240674-26r1-3D240673-26r2-3D240674-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=t4c57bn1tDTH0uH4hxsCVsOlRsCp9ovqnt_Ct-eSByo&s=P9eMFxeq_cRuXBKSzVZFzpnEmWfwT4_SUOggKKojN2g&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=240674&r1=240673&r2=240674&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Driver.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Jun 25 13:51:37 2015<br>
@@ -83,11 +83,11 @@ void Driver::ParseDriverMode(ArrayRef<co<br>
   const std::string OptName =<br>
     getOpts().getOption(options::OPT_driver_mode).getPrefixedName();<br>
<br>
-  for (size_t I = 0, E = Args.size(); I != E; ++I) {<br>
+  for (const char *ArgPtr : Args) {<br>
     // Ingore nullptrs, they are response file's EOL markers<br>
-    if (Args[I] == nullptr)<br>
+    if (ArgPtr == nullptr)<br>
       continue;<br>
-    const StringRef Arg = Args[I];<br>
+    const StringRef Arg = ArgPtr;<br>
     if (!Arg.startswith(OptName))<br>
       continue;<br>
<br>
@@ -613,10 +613,9 @@ int Driver::ExecuteCompilation(Compilati<br>
<br>
   // Otherwise, remove result files and print extra information about abnormal<br>
   // failures.<br>
-  for (SmallVectorImpl< std::pair<int, const Command *> >::iterator it =<br>
-         FailingCommands.begin(), ie = FailingCommands.end(); it != ie; ++it) {<br>
-    int Res = it->first;<br>
-    const Command *FailingCommand = it->second;<br>
+  for (const auto &CmdPair : FailingCommands) {<br>
+    int Res = CmdPair.first;<br>
+    const Command *FailingCommand = CmdPair.second;<br>
<br>
     // Remove result files if we're not saving temps.<br>
     if (!isSaveTempsEnabled()) {<br>
@@ -792,13 +791,11 @@ bool Driver::HandleImmediateArgs(const C<br>
   }<br>
<br>
   if (C.getArgs().hasArg(options::OPT_print_multi_directory)) {<br>
-    const MultilibSet &Multilibs = TC.getMultilibs();<br>
-    for (MultilibSet::const_iterator I = Multilibs.begin(), E = Multilibs.end();<br>
-         I != E; ++I) {<br>
-      if (I->gccSuffix().empty())<br>
+    for (const auto &Multilib : TC.getMultilibs()) {<br>
+      if (Multilib.gccSuffix().empty())<br>
         llvm::outs() << ".\n";<br>
       else {<br>
-        StringRef Suffix(I->gccSuffix());<br>
+        StringRef Suffix(Multilib.gccSuffix());<br>
         assert(Suffix.front() == '/');<br>
         llvm::outs() << Suffix.substr(1) << "\n";<br>
       }<br>
<br>
Modified: cfe/trunk/lib/Driver/ToolChains.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Driver_ToolChains.cpp-3Frev-3D240674-26r1-3D240673-26r2-3D240674-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=t4c57bn1tDTH0uH4hxsCVsOlRsCp9ovqnt_Ct-eSByo&s=msuDW4F8qtPstMjTmnTFNKq6hEtbQGG8uuiAj36uQZ8&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=240674&r1=240673&r2=240674&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)<br>
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Jun 25 13:51:37 2015<br>
@@ -697,11 +697,9 @@ DerivedArgList *MachO::TranslateArgs(con<br>
       // "input arguments".<br>
       if (A->getOption().hasFlag(options::LinkerInput)) {<br>
         // Convert the argument into individual Zlinker_input_args.<br>
-        for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) {<br>
-          DAL->AddSeparateArg(OriginalArg,<br>
-                              Opts.getOption(options::OPT_Zlinker_input),<br>
-                              A->getValue(i));<br>
-<br>
+        for (const char *Value : A->getValues()) {<br>
+          DAL->AddSeparateArg(<br>
+              OriginalArg, Opts.getOption(options::OPT_Zlinker_input), Value);<br>
         }<br>
         continue;<br>
       }<br>
@@ -1231,25 +1229,22 @@ Generic_GCC::GCCInstallationDetector::in<br>
   // Loop over the various components which exist and select the best GCC<br>
   // installation available. GCC installs are ranked by version number.<br>
   Version = GCCVersion::Parse("0.0.0");<br>
-  for (unsigned i = 0, ie = Prefixes.size(); i < ie; ++i) {<br>
-    if (!llvm::sys::fs::exists(Prefixes[i]))<br>
+  for (const std::string &Prefix : Prefixes) {<br>
+    if (!llvm::sys::fs::exists(Prefix))<br>
       continue;<br>
-    for (unsigned j = 0, je = CandidateLibDirs.size(); j < je; ++j) {<br>
-      const std::string LibDir = Prefixes[i] + CandidateLibDirs[j].str();<br>
+    for (const StringRef Suffix : CandidateLibDirs) {<br>
+      const std::string LibDir = Prefix + Suffix.str();<br>
       if (!llvm::sys::fs::exists(LibDir))<br>
         continue;<br>
-      for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k)<br>
-        ScanLibDirForGCCTriple(TargetTriple, Args, LibDir,<br>
-                               CandidateTripleAliases[k]);<br>
+      for (const StringRef Candidate : CandidateTripleAliases)<br>
+        ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate);<br>
     }<br>
-    for (unsigned j = 0, je = CandidateBiarchLibDirs.size(); j < je; ++j) {<br>
-      const std::string LibDir = Prefixes[i] + CandidateBiarchLibDirs[j].str();<br>
+    for (const StringRef Suffix : CandidateBiarchLibDirs) {<br>
+      const std::string LibDir = Prefix + Suffix.str();<br>
       if (!llvm::sys::fs::exists(LibDir))<br>
         continue;<br>
-      for (unsigned k = 0, ke = CandidateBiarchTripleAliases.size(); k < ke;<br>
-           ++k)<br>
-        ScanLibDirForGCCTriple(TargetTriple, Args, LibDir,<br>
-                               CandidateBiarchTripleAliases[k],<br>
+      for (const StringRef Candidate : CandidateBiarchTripleAliases)<br>
+        ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate,<br>
                                /*NeedsBiarchSuffix=*/ true);<br>
     }<br>
   }<br>
@@ -2165,9 +2160,9 @@ static void GetHexagonLibraryPaths(<br>
   //----------------------------------------------------------------------------<br>
   // -L Args<br>
   //----------------------------------------------------------------------------<br>
-  for (const Arg *A : Args.filtered(options::OPT_L))<br>
-    for (unsigned i = 0, e = A->getNumValues(); i != e; ++i)<br>
-      LibPaths->push_back(A->getValue(i));<br>
+  for (Arg *A : Args.filtered(options::OPT_L))<br>
+    for (const char *Value : A->getValues())<br>
+      LibPaths->push_back(Value);<br>
<br>
   //----------------------------------------------------------------------------<br>
   // Other standard paths<br>
@@ -2959,25 +2954,25 @@ static Distro DetectDistro(llvm::Triple:<br>
     SmallVector<StringRef, 16> Lines;<br>
     Data.split(Lines, "\n");<br>
     Distro Version = UnknownDistro;<br>
-    for (unsigned i = 0, s = Lines.size(); i != s; ++i)<br>
-      if (Version == UnknownDistro && Lines[i].startswith("DISTRIB_CODENAME="))<br>
-        Version = llvm::StringSwitch<Distro>(Lines[i].substr(17))<br>
-          .Case("hardy", UbuntuHardy)<br>
-          .Case("intrepid", UbuntuIntrepid)<br>
-          .Case("jaunty", UbuntuJaunty)<br>
-          .Case("karmic", UbuntuKarmic)<br>
-          .Case("lucid", UbuntuLucid)<br>
-          .Case("maverick", UbuntuMaverick)<br>
-          .Case("natty", UbuntuNatty)<br>
-          .Case("oneiric", UbuntuOneiric)<br>
-          .Case("precise", UbuntuPrecise)<br>
-          .Case("quantal", UbuntuQuantal)<br>
-          .Case("raring", UbuntuRaring)<br>
-          .Case("saucy", UbuntuSaucy)<br>
-          .Case("trusty", UbuntuTrusty)<br>
-          .Case("utopic", UbuntuUtopic)<br>
-          .Case("vivid", UbuntuVivid)<br>
-          .Default(UnknownDistro);<br>
+    for (const StringRef Line : Lines)<br>
+      if (Version == UnknownDistro && Line.startswith("DISTRIB_CODENAME="))<br>
+        Version = llvm::StringSwitch<Distro>(Line.substr(17))<br>
+                      .Case("hardy", UbuntuHardy)<br>
+                      .Case("intrepid", UbuntuIntrepid)<br>
+                      .Case("jaunty", UbuntuJaunty)<br>
+                      .Case("karmic", UbuntuKarmic)<br>
+                      .Case("lucid", UbuntuLucid)<br>
+                      .Case("maverick", UbuntuMaverick)<br>
+                      .Case("natty", UbuntuNatty)<br>
+                      .Case("oneiric", UbuntuOneiric)<br>
+                      .Case("precise", UbuntuPrecise)<br>
+                      .Case("quantal", UbuntuQuantal)<br>
+                      .Case("raring", UbuntuRaring)<br>
+                      .Case("saucy", UbuntuSaucy)<br>
+                      .Case("trusty", UbuntuTrusty)<br>
+                      .Case("utopic", UbuntuUtopic)<br>
+                      .Case("vivid", UbuntuVivid)<br>
+                      .Default(UnknownDistro);<br>
     return Version;<br>
   }<br>
<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Driver_Tools.cpp-3Frev-3D240674-26r1-3D240673-26r2-3D240674-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=t4c57bn1tDTH0uH4hxsCVsOlRsCp9ovqnt_Ct-eSByo&s=zSlf4lB3ULRH-H9jWRikfXoYAb8GEHeJ6pEpA9s5MUc&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=240674&r1=240673&r2=240674&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Jun 25 13:51:37 2015<br>
@@ -2188,8 +2188,7 @@ static void CollectArgsForIntegratedAsse<br>
          Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {<br>
       A->claim();<br>
<br>
-      for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) {<br>
-        StringRef Value = A->getValue(i);<br>
+      for (const StringRef Value : A->getValues()) {<br>
         if (TakeNextArg) {<br>
           CmdArgs.push_back(Value.data());<br>
           TakeNextArg = false;<br>
@@ -4828,9 +4827,9 @@ void Clang::ConstructJob(Compilation &C,<br>
<br>
     SmallString<256> Flags;<br>
     Flags += Exec;<br>
-    for (unsigned i = 0, e = OriginalArgs.size(); i != e; ++i) {<br>
+    for (const char *OriginalArg : OriginalArgs) {<br>
       SmallString<128> EscapedArg;<br>
-      EscapeSpacesAndBackslashes(OriginalArgs[i], EscapedArg);<br>
+      EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);<br>
       Flags += " ";<br>
       Flags += EscapedArg;<br>
     }<br>
@@ -5291,9 +5290,9 @@ void ClangAs::ConstructJob(Compilation &<br>
     SmallString<256> Flags;<br>
     const char *Exec = getToolChain().getDriver().getClangProgramPath();<br>
     Flags += Exec;<br>
-    for (unsigned i = 0, e = OriginalArgs.size(); i != e; ++i) {<br>
+    for (const char *OriginalArg : OriginalArgs) {<br>
       SmallString<128> EscapedArg;<br>
-      EscapeSpacesAndBackslashes(OriginalArgs[i], EscapedArg);<br>
+      EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);<br>
       Flags += " ";<br>
       Flags += EscapedArg;<br>
     }<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>