This revision was automatically updated to reflect the committed changes.
Closed by commit rL345370: Reapply: [Driver] Use forward slashes in most linker 
arguments (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53066?vs=170989&id=171253#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53066

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3570,7 +3570,8 @@
     for (const auto &II : Inputs) {
       addDashXForInput(Args, II, CmdArgs);
       if (II.isFilename())
-        CmdArgs.push_back(II.getFilename());
+        CmdArgs.push_back(
+            Args.MakeArgString(TC.normalizePath(II.getFilename())));
       else
         II.getInputArg().renderAsInput(Args, CmdArgs);
     }
@@ -4963,7 +4964,8 @@
     // Handled with other dependency code.
   } else if (Output.isFilename()) {
     CmdArgs.push_back("-o");
-    CmdArgs.push_back(Output.getFilename());
+    CmdArgs.push_back(
+        Args.MakeArgString(TC.normalizePath(Output.getFilename())));
   } else {
     assert(Output.isNothing() && "Invalid output.");
   }
@@ -4978,7 +4980,8 @@
 
   for (const InputInfo &Input : FrontendInputs) {
     if (Input.isFilename())
-      CmdArgs.push_back(Input.getFilename());
+      CmdArgs.push_back(
+          Args.MakeArgString(TC.normalizePath(Input.getFilename())));
     else
       Input.getInputArg().renderAsInput(Args, CmdArgs);
   }
@@ -5671,9 +5674,10 @@
   assert(Inputs.size() == 1 && "Unexpected number of inputs.");
   const InputInfo &Input = Inputs[0];
 
-  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
+  const ToolChain &TC = getToolChain();
+  const llvm::Triple &Triple = TC.getEffectiveTriple();
   const std::string &TripleStr = Triple.getTriple();
-  const auto &D = getToolChain().getDriver();
+  const auto &D = TC.getDriver();
 
   // Don't warn about "clang -w -c foo.s"
   Args.ClaimAllArgs(options::OPT_w);
@@ -5847,7 +5851,7 @@
 
   assert(Output.isFilename() && "Unexpected lipo output.");
   CmdArgs.push_back("-o");
-  CmdArgs.push_back(Output.getFilename());
+  CmdArgs.push_back(Args.MakeArgString(TC.normalizePath(Output.getFilename())));
 
   const llvm::Triple &T = getToolChain().getTriple();
   if (Args.hasArg(options::OPT_gsplit_dwarf) &&
@@ -5857,7 +5861,7 @@
   }
 
   assert(Input.isFilename() && "Invalid input.");
-  CmdArgs.push_back(Input.getFilename());
+  CmdArgs.push_back(Args.MakeArgString(TC.normalizePath(Input.getFilename())));
 
   const char *Exec = getToolChain().getDriver().getClangProgramPath();
   C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -1699,7 +1699,7 @@
     if (GCCToolchainDir.back() == '/')
       GCCToolchainDir = GCCToolchainDir.drop_back(); // remove the /
 
-    Prefixes.push_back(GCCToolchainDir);
+    Prefixes.push_back(llvm::sys::path::convert_to_slash(GCCToolchainDir));
   } else {
     // If we have a SysRoot, try that first.
     if (!D.SysRoot.empty()) {
Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -163,7 +163,7 @@
 
     // Add filenames immediately.
     if (II.isFilename()) {
-      CmdArgs.push_back(II.getFilename());
+      CmdArgs.push_back(Args.MakeArgString(TC.normalizePath(II.getFilename())));
       continue;
     }
 
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -376,17 +376,18 @@
 
   for (const auto &LibPath : getLibraryPaths()) {
     SmallString<128> P(LibPath);
-    llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + Suffix);
+    llvm::sys::path::append(P,
+                            Prefix + Twine("clang_rt.") + Component + Suffix);
     if (getVFS().exists(P))
-      return P.str();
+      return normalizePath(P);
   }
 
   StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
   const char *Env = TT.isAndroid() ? "-android" : "";
   SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
                                     Arch + Env + Suffix);
-  return Path.str();
+  return normalizePath(Path);
 }
 
 const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList &Args,
@@ -425,7 +426,7 @@
 }
 
 std::string ToolChain::GetFilePath(const char *Name) const {
-  return D.GetFilePath(Name, *this);
+  return normalizePath(D.GetFilePath(Name, *this));
 }
 
 std::string ToolChain::GetProgramPath(const char *Name) const {
@@ -774,12 +775,14 @@
 void ToolChain::AddFilePathLibArgs(const ArgList &Args,
                                    ArgStringList &CmdArgs) const {
   for (const auto &LibPath : getLibraryPaths())
-    if(LibPath.length() > 0)
-      CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+    if (LibPath.length() > 0)
+      CmdArgs.push_back(
+          Args.MakeArgString(StringRef("-L") + normalizePath(LibPath)));
 
   for (const auto &LibPath : getFilePaths())
-    if(LibPath.length() > 0)
-      CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+    if (LibPath.length() > 0)
+      CmdArgs.push_back(
+          Args.MakeArgString(StringRef("-L") + normalizePath(LibPath)));
 }
 
 void ToolChain::AddCCKextLibArgs(const ArgList &Args,
Index: cfe/trunk/lib/Driver/Driver.cpp
===================================================================
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1011,6 +1011,12 @@
                     .Default(SaveTempsCwd);
   }
 
+  llvm::Triple EffectiveTriple = computeTargetTriple(*this, TargetTriple, Args);
+  if (!EffectiveTriple.isOSWindows() || EffectiveTriple.isOSCygMing()) {
+    for (auto *Str : {&Dir, &InstalledDir, &SysRoot, &ResourceDir})
+      *Str = llvm::sys::path::convert_to_slash(*Str);
+  }
+
   setLTOMode(Args);
 
   // Process -fembed-bitcode= flags.
Index: cfe/trunk/include/clang/Driver/ToolChain.h
===================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/MC/MCTargetOptions.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/Target/TargetOptions.h"
 #include <cassert>
@@ -370,6 +371,12 @@
                                      StringRef Component,
                                      bool Shared = false) const;
 
+  std::string normalizePath(StringRef Path) const {
+    if (!Triple.isOSWindows() || Triple.isOSCygMing())
+      return llvm::sys::path::convert_to_slash(Path);
+    return Path;
+  }
+
   // Returns <ResourceDir>/lib/<OSName>/<arch>.  This is used by runtimes (such
   // as OpenMP) to find arch-specific libraries.
   std::string getArchSpecificLibPath() const;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to