diff options
Diffstat (limited to 'clang/lib/Basic/VirtualFileSystem.cpp')
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index dc0f52f72b4..28bb5989341 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -582,9 +582,11 @@ class VFSFromYAMLParser { return NULL; } - // Remove trailing slash(es) + // Remove trailing slash(es), being careful not to remove the root path StringRef Trimmed(Name); - while (Trimmed.size() > 1 && sys::path::is_separator(Trimmed.back())) + size_t RootPathLen = sys::path::root_path(Trimmed).size(); + while (Trimmed.size() > RootPathLen && + sys::path::is_separator(Trimmed.back())) Trimmed = Trimmed.slice(0, Trimmed.size()-1); // Get the last component StringRef LastComponent = sys::path::filename(Trimmed); |