diff options
author | Douglas Katzman <dougk@google.com> | 2015-08-14 15:52:12 +0000 |
---|---|---|
committer | Douglas Katzman <dougk@google.com> | 2015-08-14 15:52:12 +0000 |
commit | cb07d15b4c5dad43eb0f93cab6586330c0d06a99 (patch) | |
tree | d30c8c59721cfa60090bb22d47ff5775ba595cfe /clang/lib/Driver/ToolChains.cpp | |
parent | dbaf0498a9009f38ce7d4ff66df50451b65e50aa (diff) | |
download | bcm5719-llvm-cb07d15b4c5dad43eb0f93cab6586330c0d06a99.tar.gz bcm5719-llvm-cb07d15b4c5dad43eb0f93cab6586330c0d06a99.zip |
Represent 2 parallel string arrays as one string[][2] array.
Differential Revision: http://reviews.llvm.org/D11991
llvm-svn: 245063
Diffstat (limited to 'clang/lib/Driver/ToolChains.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChains.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index 1e27d0a2df9..7d6d257fcb0 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -1914,34 +1914,33 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( llvm::Triple::ArchType TargetArch = TargetTriple.getArch(); // There are various different suffixes involving the triple we // check for. We also record what is necessary to walk from each back - // up to the lib directory. - const std::string LibSuffixes[] = { - "/gcc/" + CandidateTriple.str(), + // up to the lib directory. Specifically, the number of "up" steps + // in the second half of each row is 1 + the number of path separators + // in the first half. + const std::string LibAndInstallSuffixes[][2] = { + {"/gcc/" + CandidateTriple.str(), "/../../.."}, + // Debian puts cross-compilers in gcc-cross - "/gcc-cross/" + CandidateTriple.str(), - "/" + CandidateTriple.str() + "/gcc/" + CandidateTriple.str(), + {"/gcc-cross/" + CandidateTriple.str(), "/../../.."}, + + {"/" + CandidateTriple.str() + "/gcc/" + CandidateTriple.str(), + "/../../../.."}, // The Freescale PPC SDK has the gcc libraries in // <sysroot>/usr/lib/<triple>/x.y.z so have a look there as well. - "/" + CandidateTriple.str(), + {"/" + CandidateTriple.str(), "/../.."}, // Ubuntu has a strange mis-matched pair of triples that this happens to // match. // FIXME: It may be worthwhile to generalize this and look for a second // triple. - "/i386-linux-gnu/gcc/" + CandidateTriple.str()}; - const std::string InstallSuffixes[] = { - "/../../..", // gcc/ - "/../../..", // gcc-cross/ - "/../../../..", // <triple>/gcc/ - "/../..", // <triple>/ - "/../../../.." // i386-linux-gnu/gcc/<triple>/ - }; + {"/i386-linux-gnu/gcc/" + CandidateTriple.str(), "/../../../.."}}; + // Only look at the final, weird Ubuntu suffix for i386-linux-gnu. - const unsigned NumLibSuffixes = - (llvm::array_lengthof(LibSuffixes) - (TargetArch != llvm::Triple::x86)); + const unsigned NumLibSuffixes = (llvm::array_lengthof(LibAndInstallSuffixes) - + (TargetArch != llvm::Triple::x86)); for (unsigned i = 0; i < NumLibSuffixes; ++i) { - StringRef LibSuffix = LibSuffixes[i]; + StringRef LibSuffix = LibAndInstallSuffixes[i][0]; std::error_code EC; for (llvm::sys::fs::directory_iterator LI(LibDir + LibSuffix, EC), LE; !EC && LI != LE; LI = LI.increment(EC)) { @@ -1975,8 +1974,9 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( // FIXME: We hack together the directory name here instead of // using LI to ensure stable path separators across Windows and // Linux. - GCCInstallPath = LibDir + LibSuffixes[i] + "/" + VersionText.str(); - GCCParentLibPath = GCCInstallPath + InstallSuffixes[i]; + GCCInstallPath = + LibDir + LibAndInstallSuffixes[i][0] + "/" + VersionText.str(); + GCCParentLibPath = GCCInstallPath + LibAndInstallSuffixes[i][1]; IsValid = true; } } |