[cfe-commits] r158596 - /cfe/trunk/lib/Basic/FileManager.cpp

NAKAMURA Takumi geek4civic at gmail.com
Fri Jun 15 23:04:10 PDT 2012


Author: chapuni
Date: Sat Jun 16 01:04:10 2012
New Revision: 158596

URL: http://llvm.org/viewvc/llvm-project?rev=158596&view=rev
Log:
clang/lib/Basic/FileManager.cpp: Detect the root directory with PathV2. It should be better fix for PR10331, or, "clang X:\foo.c" fails.

Modified:
    cfe/trunk/lib/Basic/FileManager.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=158596&r1=158595&r2=158596&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Sat Jun 16 01:04:10 2012
@@ -261,10 +261,12 @@
 
 const DirectoryEntry *FileManager::getDirectory(StringRef DirName,
                                                 bool CacheFailure) {
-  // stat doesn't like trailing separators.
+  // stat doesn't like trailing separators except for root directory.
   // At least, on Win32 MSVCRT, stat() cannot strip trailing '/'.
   // (though it can strip '\\')
-  if (DirName.size() > 1 && llvm::sys::path::is_separator(DirName.back()))
+  if (DirName.size() > 1 &&
+      DirName != llvm::sys::path::root_path(DirName) &&
+      llvm::sys::path::is_separator(DirName.back()))
     DirName = DirName.substr(0, DirName.size()-1);
 
   ++NumDirLookups;





More information about the cfe-commits mailing list