[PATCH] D54503: [HeaderSearch] loadSubdirectoryModuleMaps should respect -working-directory
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 13 16:28:25 PST 2018
arphaman created this revision.
arphaman added a reviewer: bruno.
Herald added a subscriber: dexonsmith.
Include search paths can be relative paths. The `loadSubdirectoryModuleMaps` function should account for that and respect the `-working-directory` parameter given to Clang.
Repository:
rC Clang
https://reviews.llvm.org/D54503
Files:
lib/Lex/HeaderSearch.cpp
test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h
test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map
test/Modules/subdirectory-module-maps-working-dir.m
Index: test/Modules/subdirectory-module-maps-working-dir.m
===================================================================
--- /dev/null
+++ test/Modules/subdirectory-module-maps-working-dir.m
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t \
+// RUN: -working-directory %S/Inputs \
+// RUN: -I subdirectory-module-maps-working-dir \
+// RUN: %s -Werror=implicit-function-declaration -Xclang -verify
+
+ at import ModuleInSubdir;
+
+void foo() {
+ int x = bar();
+}
+
+// expected-no-diagnostics
Index: test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map
===================================================================
--- /dev/null
+++ test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map
@@ -0,0 +1,5 @@
+module ModuleInSubdir {
+header "h1.h"
+ export *
+}
+
Index: test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h
@@ -0,0 +1 @@
+int bar();
Index: lib/Lex/HeaderSearch.cpp
===================================================================
--- lib/Lex/HeaderSearch.cpp
+++ lib/Lex/HeaderSearch.cpp
@@ -1638,8 +1638,10 @@
return;
std::error_code EC;
+ SmallString<128> Dir = SearchDir.getDir()->getName();
+ FileMgr.makeAbsolutePath(Dir);
SmallString<128> DirNative;
- llvm::sys::path::native(SearchDir.getDir()->getName(), DirNative);
+ llvm::sys::path::native(Dir, DirNative);
llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54503.173958.patch
Type: text/x-patch
Size: 1811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181114/ab63637e/attachment.bin>
More information about the cfe-commits
mailing list