[PATCH] D67091: Fix for headers having the same name as a directory
Kousik Kumar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 12 05:17:20 PDT 2019
kousikk updated this revision to Diff 219891.
kousikk added a comment.
- Add validation inside the createFile() function
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67091/new/
https://reviews.llvm.org/D67091
Files:
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -176,6 +176,8 @@
llvm::ErrorOr<StringRef> Contents = Entry->getContents();
if (!Contents)
return Contents.getError();
+ if (Entry->isDirectory())
+ return llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>(std::make_error_code(std::errc::is_a_directory));
return std::make_unique<MinimizedVFSFile>(
llvm::MemoryBuffer::getMemBuffer(*Contents, Entry->getName(),
/*RequiresNullTerminator=*/false),
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
===================================================================
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -55,6 +55,11 @@
/// \returns True if the entry is valid.
bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); }
+ /// \returns True if the current entry points to a directory.
+ bool isDirectory() const {
+ return MaybeStat && MaybeStat->isDirectory();
+ }
+
/// \returns The error or the file's contents.
llvm::ErrorOr<StringRef> getContents() const {
if (!MaybeStat)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67091.219891.patch
Type: text/x-patch
Size: 1487 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190912/02ab4799/attachment.bin>
More information about the cfe-commits
mailing list