[PATCH] Fixing a driver bug where clang cannot locate source file at drive root

Yunzhong Gao Yunzhong_Gao at playstation.sony.com
Tue Jul 2 13:18:39 PDT 2013


  Hi Arthur,
  I just tried on my Windows 7 machine, and I think you are right about it. C:test.c actually means the file test.c under the current working directory in C: drive, not C:\test.c. I updated my patch accordingly.
  Thanks!
  - Gao.

http://llvm-reviews.chandlerc.com/D937

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D937?vs=2317&id=2653#toc

Files:
  lib/Basic/FileManager.cpp

Index: lib/Basic/FileManager.cpp
===================================================================
--- lib/Basic/FileManager.cpp
+++ lib/Basic/FileManager.cpp
@@ -293,6 +293,17 @@
       llvm::sys::path::is_separator(DirName.back()))
     DirName = DirName.substr(0, DirName.size()-1);

+#ifdef LLVM_ON_WIN32
+  // Fixing a problem with "clang C:test.c" on Windows.
+  // Stat("C:") does not recognize "C:" as a valid directory
+  std::string DirNameStr;
+  if (DirName.size() > 1 && DirName.back() == ':' &&
+      DirName.equals_lower(llvm::sys::path::root_name(DirName))) {
+    DirNameStr = DirName.str() + '.';
+    DirName = DirNameStr;
+  }
+#endif
+
   ++NumDirLookups;
   llvm::StringMapEntry<DirectoryEntry *> &NamedDirEnt =
     SeenDirEntries.GetOrCreateValue(DirName);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D937.2.patch
Type: text/x-patch
Size: 784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130702/1218447a/attachment.bin>


More information about the cfe-commits mailing list