[PATCH] D67091: Fix for headers having the same name as a directory
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 13 15:10:22 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371903: [clang-scan-deps] Fix for headers having the same name as a directory (authored by arphaman, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D67091?vs=219976&id=220181#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67091/new/
https://reviews.llvm.org/D67091
Files:
cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
cfe/trunk/test/ClangScanDeps/Inputs/foodir
cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json
cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp
Index: cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===================================================================
--- cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -193,6 +193,9 @@
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();
Index: cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
===================================================================
--- cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -56,6 +56,9 @@
/// \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)
Index: cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp
===================================================================
--- cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp
+++ cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname_input.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include <foodir>
+
+// CHECK: headerwithdirname_input.o
+// CHECK-NEXT: headerwithdirname_input.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir
Index: cfe/trunk/test/ClangScanDeps/Inputs/foodir
===================================================================
--- cfe/trunk/test/ClangScanDeps/Inputs/foodir
+++ cfe/trunk/test/ClangScanDeps/Inputs/foodir
@@ -0,0 +1 @@
+// A C++ header with same name as that of a directory in the include path.
Index: cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json
===================================================================
--- cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json
+++ cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -0,0 +1,7 @@
+[
+ {
+ "directory": "DIR",
+ "command": "clang -c -IDIR -IDIR/foodir -IInputs DIR/headerwithdirname_input.cpp",
+ "file": "DIR/headerwithdirname_input.cpp"
+ }
+]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67091.220181.patch
Type: text/x-patch
Size: 3065 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190913/9bcc751c/attachment.bin>
More information about the cfe-commits
mailing list