From 8250364e5008fd7a8c0109022d60fd62698838d9 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 12 Apr 2016 16:33:53 +0000 Subject: [PATCH] [FileManager] Don't crash if reading from stdin and stat(".") fails addAncestorsAsVirtualDirs("") quickly returns without doing work because "" has no parent_path. This violates the expectation that a subsequent call to getDirectoryFromFile("") would succeed. Instead, it fails because it uses the "." if the file has no path component. Fix this by keeping the behavior between addAncestorsAsVirtualDirs and getDirectoryFromFile symmetric. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266089 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/FileManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index ba016db011..c4cc8dc541 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -123,7 +123,7 @@ static const DirectoryEntry *getDirectoryFromFile(FileManager &FileMgr, void FileManager::addAncestorsAsVirtualDirs(StringRef Path) { StringRef DirName = llvm::sys::path::parent_path(Path); if (DirName.empty()) - return; + DirName = "."; auto &NamedDirEnt = *SeenDirEntries.insert(std::make_pair(DirName, nullptr)).first; -- 2.40.0