]> granicus.if.org Git - clang/commit
[FileManager] Don't crash if reading from stdin and stat(".") fails
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 12 Apr 2016 16:33:53 +0000 (16:33 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 12 Apr 2016 16:33:53 +0000 (16:33 +0000)
commit8250364e5008fd7a8c0109022d60fd62698838d9
treefd88cfa7584e58414e90c685d6526addd7fed7e2
parent3ce75a28c389098a60b47f07a80f8713dee3f5b1
[FileManager] Don't crash if reading from stdin and stat(".") fails

addAncestorsAsVirtualDirs("<stdin>") quickly returns without doing work
because "<stdin>" has no parent_path.  This violates the expectation
that a subsequent call to getDirectoryFromFile("<stdin>") 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