From bac35bd8530000c1e3840f8ccdad8b82f4bc3d8b Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Fri, 13 Sep 2019 22:12:02 +0000 Subject: [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 --- lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/Tooling') 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> createFile(const CachedFileSystemEntry *Entry, ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings) { + if (Entry->isDirectory()) + return llvm::ErrorOr>( + std::make_error_code(std::errc::is_a_directory)); llvm::ErrorOr Contents = Entry->getContents(); if (!Contents) return Contents.getError(); -- cgit v1.2.1