]> granicus.if.org Git - clang/commitdiff
clang/lib/Basic/FileManager.cpp: Detect the root directory with PathV2. It should...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sat, 16 Jun 2012 06:04:10 +0000 (06:04 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sat, 16 Jun 2012 06:04:10 +0000 (06:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158596 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/FileManager.cpp

index 5b9769dbb95a4337b6450a01bee86fe5807a2088..75333f8fb55bda55c6e775afed7eabacbcc484c0 100644 (file)
@@ -261,10 +261,12 @@ void FileManager::addAncestorsAsVirtualDirs(StringRef Path) {
 
 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;