diff options
author | Alex Lorenz <arphaman@gmail.com> | 2019-09-13 22:12:02 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2019-09-13 22:12:02 +0000 |
commit | bac35bd8530000c1e3840f8ccdad8b82f4bc3d8b (patch) | |
tree | a2be9e7e7ec07c60f12386ed115a0cf2f040d0ef /lib/Tooling | |
parent | 7343eabc6b4054b7ca2f4455361d5f891f482626 (diff) | |
download | clang-bac35bd8530000c1e3840f8ccdad8b82f4bc3d8b.tar.gz |
[clang-scan-deps] Fix for headers having the same name as a directory
Scan deps tool crashes when called on a C++ file, containing an include
that has the same name as a directory.
The tool crashes since it finds foo/dir and tries to read that as a file and fails.
Patch by: kousikk (Kousik Kumar)
Differential Revision: https://reviews.llvm.org/D67091
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371903 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling')
-rw-r--r-- | lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp b/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp index 7a3d189ada..35ecbd4a7f 100644 --- a/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp +++ b/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp @@ -193,6 +193,9 @@ private: llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>> createFile(const CachedFileSystemEntry *Entry, ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings) { + if (Entry->isDirectory()) + return llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>( + std::make_error_code(std::errc::is_a_directory)); llvm::ErrorOr<StringRef> Contents = Entry->getContents(); if (!Contents) return Contents.getError(); |