From: Chandler Carruth Date: Tue, 24 Jan 2012 19:28:29 +0000 (+0000) Subject: Address one part of the FIXME I introduced my switching the triple X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa5be916273be4d2e0ef8db050c8bdd404b95555;p=clang Address one part of the FIXME I introduced my switching the triple inside of GCCInstallation to be a proper llvm::Triple. This is still a touch ugly because we have to use it as a string in so many places, but I think on the whole the more structured representation is better. Comments of course welcome if this tradeoff isn't working for folks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148843 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 3db63cd06b..a2a4748334 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1100,9 +1100,8 @@ bool Generic_GCC::GCCVersion::operator<(const GCCVersion &RHS) const { Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(const Driver &D) : IsValid(false), // FIXME: GCCTriple is using the target triple as both the target and host - // triple here. It also shouldn't be using the string representation, and - // should instead be using the Triple object. - GCCTriple(D.TargetTriple.str()) { + // triple here. + GCCTriple(D.TargetTriple) { // FIXME: Using CXX_INCLUDE_ROOT is here is a bit of a hack, but // avoids adding yet another option to configure/cmake. // It would probably be cleaner to break it in two variables @@ -1131,7 +1130,7 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(const Driver &D) return; } - llvm::Triple::ArchType HostArch = llvm::Triple(GCCTriple).getArch(); + llvm::Triple::ArchType HostArch = GCCTriple.getArch(); // The library directories which may contain GCC installations. SmallVector CandidateLibDirs; // The compatible GCC triples for this particular architecture. @@ -1296,7 +1295,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( continue; Version = CandidateVersion; - GCCTriple = CandidateTriple.str(); + GCCTriple.setTriple(CandidateTriple); // FIXME: We hack together the directory name here instead of // using LI to ensure stable path separators across Windows and // Linux. @@ -1906,7 +1905,7 @@ Linux::Linux(const HostInfo &Host, const llvm::Triple &Triple) // path. ToolChain::path_list &PPaths = getProgramPaths(); PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" + - GCCInstallation.getTriple() + "/bin").str()); + GCCInstallation.getTriple().str() + "/bin").str()); Linker = GetProgramPath("ld"); @@ -1983,9 +1982,9 @@ Linux::Linux(const HostInfo &Host, const llvm::Triple &Triple) // Add the multilib suffixed paths where they are available. if (GCCInstallation.isValid()) { const std::string &LibPath = GCCInstallation.getParentLibPath(); - const std::string &GCCTriple = GCCInstallation.getTriple(); + const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); addPathIfExists(GCCInstallation.getInstallPath() + Suffix, Paths); - addPathIfExists(LibPath + "/../" + GCCTriple + "/lib/../" + Multilib, + addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib/../" + Multilib, Paths); addPathIfExists(LibPath + "/" + MultiarchTriple, Paths); addPathIfExists(LibPath + "/../" + Multilib, Paths); @@ -1998,16 +1997,16 @@ Linux::Linux(const HostInfo &Host, const llvm::Triple &Triple) // Try walking via the GCC triple path in case of multiarch GCC // installations with strange symlinks. if (GCCInstallation.isValid()) - addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple() + + addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() + "/../../" + Multilib, Paths); // Add the non-multilib suffixed paths (if potentially different). if (GCCInstallation.isValid()) { const std::string &LibPath = GCCInstallation.getParentLibPath(); - const std::string &GCCTriple = GCCInstallation.getTriple(); + const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); if (!Suffix.empty()) addPathIfExists(GCCInstallation.getInstallPath(), Paths); - addPathIfExists(LibPath + "/../" + GCCTriple + "/lib", Paths); + addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib", Paths); addPathIfExists(LibPath, Paths); } addPathIfExists(SysRoot + "/lib", Paths); @@ -2208,12 +2207,12 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, StringRef InstallDir = GCCInstallation.getInstallPath(); StringRef Version = GCCInstallation.getVersion(); if (!addLibStdCXXIncludePaths(LibDir + "/../include/c++/" + Version, - GCCInstallation.getTriple() + Suffix, + GCCInstallation.getTriple().str() + Suffix, DriverArgs, CC1Args)) { // Gentoo is weird and places its headers inside the GCC install, so if the // first attempt to find the headers fails, try this pattern. addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4", - GCCInstallation.getTriple() + Suffix, + GCCInstallation.getTriple().str() + Suffix, DriverArgs, CC1Args); } } diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 6f9e5bf514..6b152f442e 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -69,7 +69,7 @@ protected: class GCCInstallationDetector { bool IsValid; - std::string GCCTriple; + llvm::Triple GCCTriple; // FIXME: These might be better as path objects. std::string GCCInstallPath; @@ -84,7 +84,7 @@ protected: bool isValid() const { return IsValid; } /// \brief Get the GCC triple for the detected install. - StringRef getTriple() const { return GCCTriple; } + const llvm::Triple &getTriple() const { return GCCTriple; } /// \brief Get the detected GCC installation path. StringRef getInstallPath() const { return GCCInstallPath; }