Fix hardcoded slash to native path seperator which was exposed from llvm::sys::path.
authorYaron Keren <yaron.keren@gmail.com>
Fri, 16 May 2014 13:16:30 +0000 (13:16 +0000)
committerYaron Keren <yaron.keren@gmail.com>
Fri, 16 May 2014 13:16:30 +0000 (13:16 +0000)
http://reviews.llvm.org/D3687

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208980 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Path.h
lib/MC/MCDwarf.cpp
lib/Support/Path.cpp
lib/Support/SourceMgr.cpp

index ba18529b48afa8fc9cb149166ea86bb235f2d7a5..cf821f0ef4a425da0e1a0e4feb2bec68a38cc322 100644 (file)
@@ -295,6 +295,11 @@ const StringRef extension(StringRef path);
 /// @result true if \a value is a path separator character on the host OS
 bool is_separator(char value);
 
+/// @brief Return the preferred separator for this platform.
+///
+/// @result StringRef of the preferred separator, null-terminated.
+const StringRef get_separator();
+
 /// @brief Get the typical temporary directory for the system, e.g., 
 /// "/var/tmp" or "C:/TEMP"
 ///
index 3ccc23f7d9e1b0e608467aa7d2d043dab7ae3c90..be6731abedd94389f14e1d0bcef62e448338c225 100644 (file)
@@ -689,7 +689,7 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
   const SmallVectorImpl<std::string> &MCDwarfDirs = context.getMCDwarfDirs();
   if (MCDwarfDirs.size() > 0) {
     MCOS->EmitBytes(MCDwarfDirs[0]);
-    MCOS->EmitBytes("/");
+    MCOS->EmitBytes(sys::path::get_separator());
   }
   const SmallVectorImpl<MCDwarfFile> &MCDwarfFiles =
     MCOS->getContext().getMCDwarfFiles();
index d345829d4dd5655f13833cf2b870c7f9d59a2304..b8d676f286c90b3010318274cc373cb975f6f07c 100644 (file)
@@ -569,6 +569,12 @@ bool is_separator(char value) {
   }
 }
 
+static const char preferred_separator_string[] = { preferred_separator, '\0' };
+
+const StringRef get_separator() {
+  return preferred_separator_string;
+}
+
 void system_temp_directory(bool erasedOnReboot, SmallVectorImpl<char> &result) {
   result.clear();
 
index ca682897968c46ac237c46d90df028166335fda3..acd75fbbd19233e9832d667d7995a4bb74be285a 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Locale.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/system_error.h"
 using namespace llvm;
@@ -60,7 +61,7 @@ size_t SourceMgr::AddIncludeFile(const std::string &Filename,
 
   // If the file didn't exist directly, see if it's in an include path.
   for (unsigned i = 0, e = IncludeDirectories.size(); i != e && !NewBuf; ++i) {
-    IncludedFile = IncludeDirectories[i] + "/" + Filename;
+    IncludedFile = IncludeDirectories[i] + sys::path::get_separator().data() + Filename;
     MemoryBuffer::getFile(IncludedFile.c_str(), NewBuf);
   }