diff options
author | Douglas Katzman <dougk@google.com> | 2015-06-25 18:51:37 +0000 |
---|---|---|
committer | Douglas Katzman <dougk@google.com> | 2015-06-25 18:51:37 +0000 |
commit | 6bbffc4b973dda097b1f139a9c9ebf9d3a3ab514 (patch) | |
tree | 6e3848743c727a2de03233e2da45e8b2dade7fee /clang/lib/Driver/ToolChains.cpp | |
parent | eb283241e8ec8122de8a8fca2b0e5a2ddb0a28be (diff) | |
download | bcm5719-llvm-6bbffc4b973dda097b1f139a9c9ebf9d3a3ab514.tar.gz bcm5719-llvm-6bbffc4b973dda097b1f139a9c9ebf9d3a3ab514.zip |
Use more range-based for loops
Differential Revision: http://reviews.llvm.org/D10738
llvm-svn: 240674
Diffstat (limited to 'clang/lib/Driver/ToolChains.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChains.cpp | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index 6ca80166506..3371861eb85 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -697,11 +697,9 @@ DerivedArgList *MachO::TranslateArgs(const DerivedArgList &Args, // "input arguments". if (A->getOption().hasFlag(options::LinkerInput)) { // Convert the argument into individual Zlinker_input_args. - for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) { - DAL->AddSeparateArg(OriginalArg, - Opts.getOption(options::OPT_Zlinker_input), - A->getValue(i)); - + for (const char *Value : A->getValues()) { + DAL->AddSeparateArg( + OriginalArg, Opts.getOption(options::OPT_Zlinker_input), Value); } continue; } @@ -1231,25 +1229,22 @@ Generic_GCC::GCCInstallationDetector::init( // Loop over the various components which exist and select the best GCC // installation available. GCC installs are ranked by version number. Version = GCCVersion::Parse("0.0.0"); - for (unsigned i = 0, ie = Prefixes.size(); i < ie; ++i) { - if (!llvm::sys::fs::exists(Prefixes[i])) + for (const std::string &Prefix : Prefixes) { + if (!llvm::sys::fs::exists(Prefix)) continue; - for (unsigned j = 0, je = CandidateLibDirs.size(); j < je; ++j) { - const std::string LibDir = Prefixes[i] + CandidateLibDirs[j].str(); + for (const StringRef Suffix : CandidateLibDirs) { + const std::string LibDir = Prefix + Suffix.str(); if (!llvm::sys::fs::exists(LibDir)) continue; - for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k) - ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, - CandidateTripleAliases[k]); + for (const StringRef Candidate : CandidateTripleAliases) + ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate); } - for (unsigned j = 0, je = CandidateBiarchLibDirs.size(); j < je; ++j) { - const std::string LibDir = Prefixes[i] + CandidateBiarchLibDirs[j].str(); + for (const StringRef Suffix : CandidateBiarchLibDirs) { + const std::string LibDir = Prefix + Suffix.str(); if (!llvm::sys::fs::exists(LibDir)) continue; - for (unsigned k = 0, ke = CandidateBiarchTripleAliases.size(); k < ke; - ++k) - ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, - CandidateBiarchTripleAliases[k], + for (const StringRef Candidate : CandidateBiarchTripleAliases) + ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate, /*NeedsBiarchSuffix=*/ true); } } @@ -2165,9 +2160,9 @@ static void GetHexagonLibraryPaths( //---------------------------------------------------------------------------- // -L Args //---------------------------------------------------------------------------- - for (const Arg *A : Args.filtered(options::OPT_L)) - for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) - LibPaths->push_back(A->getValue(i)); + for (Arg *A : Args.filtered(options::OPT_L)) + for (const char *Value : A->getValues()) + LibPaths->push_back(Value); //---------------------------------------------------------------------------- // Other standard paths @@ -2959,25 +2954,25 @@ static Distro DetectDistro(llvm::Triple::ArchType Arch) { SmallVector<StringRef, 16> Lines; Data.split(Lines, "\n"); Distro Version = UnknownDistro; - for (unsigned i = 0, s = Lines.size(); i != s; ++i) - if (Version == UnknownDistro && Lines[i].startswith("DISTRIB_CODENAME=")) - Version = llvm::StringSwitch<Distro>(Lines[i].substr(17)) - .Case("hardy", UbuntuHardy) - .Case("intrepid", UbuntuIntrepid) - .Case("jaunty", UbuntuJaunty) - .Case("karmic", UbuntuKarmic) - .Case("lucid", UbuntuLucid) - .Case("maverick", UbuntuMaverick) - .Case("natty", UbuntuNatty) - .Case("oneiric", UbuntuOneiric) - .Case("precise", UbuntuPrecise) - .Case("quantal", UbuntuQuantal) - .Case("raring", UbuntuRaring) - .Case("saucy", UbuntuSaucy) - .Case("trusty", UbuntuTrusty) - .Case("utopic", UbuntuUtopic) - .Case("vivid", UbuntuVivid) - .Default(UnknownDistro); + for (const StringRef Line : Lines) + if (Version == UnknownDistro && Line.startswith("DISTRIB_CODENAME=")) + Version = llvm::StringSwitch<Distro>(Line.substr(17)) + .Case("hardy", UbuntuHardy) + .Case("intrepid", UbuntuIntrepid) + .Case("jaunty", UbuntuJaunty) + .Case("karmic", UbuntuKarmic) + .Case("lucid", UbuntuLucid) + .Case("maverick", UbuntuMaverick) + .Case("natty", UbuntuNatty) + .Case("oneiric", UbuntuOneiric) + .Case("precise", UbuntuPrecise) + .Case("quantal", UbuntuQuantal) + .Case("raring", UbuntuRaring) + .Case("saucy", UbuntuSaucy) + .Case("trusty", UbuntuTrusty) + .Case("utopic", UbuntuUtopic) + .Case("vivid", UbuntuVivid) + .Default(UnknownDistro); return Version; } |