10ne1 updated this revision to Diff 463465.
10ne1 marked an inline comment as done.
10ne1 edited the summary of this revision.
Herald added subscribers: atanasyan, arichardson, sdardis.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134454/new/

https://reviews.llvm.org/D134454

Files:
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -355,40 +355,31 @@
       return AndroidSysRootPath;
   }
 
-  if (getTriple().isCSKY()) {
-    // CSKY toolchains use different names for sysroot folder.
-    if (!GCCInstallation.isValid())
-      return std::string();
-    // GCCInstallation.getInstallPath() =
-    //   $GCCToolchainPath/lib/gcc/csky-linux-gnuabiv2/6.3.0
-    // Path = $GCCToolchainPath/csky-linux-gnuabiv2/libc
-    std::string Path = (GCCInstallation.getInstallPath() + "/../../../../" +
-                        GCCInstallation.getTriple().str() + "/libc")
-                           .str();
-    if (getVFS().exists(Path))
-      return Path;
-    return std::string();
-  }
-
-  if (!GCCInstallation.isValid() || !getTriple().isMIPS())
+  if (!GCCInstallation.isValid())
     return std::string();
 
-  // Standalone MIPS toolchains use different names for sysroot folder
-  // and put it into different places. Here we try to check some known
-  // variants.
-
   const StringRef InstallDir = GCCInstallation.getInstallPath();
   const StringRef TripleStr = GCCInstallation.getTriple().str();
-  const Multilib &Multilib = GCCInstallation.getMultilib();
+  std::string Path = (InstallDir + "/../../../../" + TripleStr).str();
 
-  std::string Path =
-      (InstallDir + "/../../../../" + TripleStr + "/libc" + 
Multilib.osSuffix())
-          .str();
+  // CSKY toolchains use different names for sysroot folder.
+  // GCCInstallation.getInstallPath() =
+  //   $GCCToolchainPath/lib/gcc/csky-linux-gnuabiv2/6.3.0
+  // Path = $GCCToolchainPath/csky-linux-gnuabiv2/libc
+  if (getTriple().isCSKY())
+    Path = Path + "/libc";
 
-  if (getVFS().exists(Path))
-    return Path;
+  // Standalone MIPS toolchains use different names for sysroot folder
+  // and put it into different places. Here we try to check some known
+  // variants.
+  if (getTriple().isMIPS()) {
+    const Multilib &Multilib = GCCInstallation.getMultilib();
+    Path = Path + "/libc" + Multilib.osSuffix();
+    if (getVFS().exists(Path))
+      return Path;
 
-  Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+    Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+  }
 
   if (getVFS().exists(Path))
     return Path;


Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -355,40 +355,31 @@
       return AndroidSysRootPath;
   }
 
-  if (getTriple().isCSKY()) {
-    // CSKY toolchains use different names for sysroot folder.
-    if (!GCCInstallation.isValid())
-      return std::string();
-    // GCCInstallation.getInstallPath() =
-    //   $GCCToolchainPath/lib/gcc/csky-linux-gnuabiv2/6.3.0
-    // Path = $GCCToolchainPath/csky-linux-gnuabiv2/libc
-    std::string Path = (GCCInstallation.getInstallPath() + "/../../../../" +
-                        GCCInstallation.getTriple().str() + "/libc")
-                           .str();
-    if (getVFS().exists(Path))
-      return Path;
-    return std::string();
-  }
-
-  if (!GCCInstallation.isValid() || !getTriple().isMIPS())
+  if (!GCCInstallation.isValid())
     return std::string();
 
-  // Standalone MIPS toolchains use different names for sysroot folder
-  // and put it into different places. Here we try to check some known
-  // variants.
-
   const StringRef InstallDir = GCCInstallation.getInstallPath();
   const StringRef TripleStr = GCCInstallation.getTriple().str();
-  const Multilib &Multilib = GCCInstallation.getMultilib();
+  std::string Path = (InstallDir + "/../../../../" + TripleStr).str();
 
-  std::string Path =
-      (InstallDir + "/../../../../" + TripleStr + "/libc" + Multilib.osSuffix())
-          .str();
+  // CSKY toolchains use different names for sysroot folder.
+  // GCCInstallation.getInstallPath() =
+  //   $GCCToolchainPath/lib/gcc/csky-linux-gnuabiv2/6.3.0
+  // Path = $GCCToolchainPath/csky-linux-gnuabiv2/libc
+  if (getTriple().isCSKY())
+    Path = Path + "/libc";
 
-  if (getVFS().exists(Path))
-    return Path;
+  // Standalone MIPS toolchains use different names for sysroot folder
+  // and put it into different places. Here we try to check some known
+  // variants.
+  if (getTriple().isMIPS()) {
+    const Multilib &Multilib = GCCInstallation.getMultilib();
+    Path = Path + "/libc" + Multilib.osSuffix();
+    if (getVFS().exists(Path))
+      return Path;
 
-  Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+    Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+  }
 
   if (getVFS().exists(Path))
     return Path;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to