r346822 - [HeaderSearch] loadSubdirectoryModuleMaps should respect -working-directory

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 13 17:08:03 PST 2018


Author: arphaman
Date: Tue Nov 13 17:08:03 2018
New Revision: 346822

URL: http://llvm.org/viewvc/llvm-project?rev=346822&view=rev
Log:
[HeaderSearch] loadSubdirectoryModuleMaps should respect -working-directory

Include search paths can be relative paths. The loadSubdirectoryModuleMaps function
should account for that and respect the -working-directory parameter given to Clang.

rdar://46045849

Differential Revision: https://reviews.llvm.org/D54503 

Added:
    cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/
    cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/
    cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h
    cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map
    cfe/trunk/test/Modules/subdirectory-module-maps-working-dir.m
Modified:
    cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=346822&r1=346821&r2=346822&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Nov 13 17:08:03 2018
@@ -1638,8 +1638,10 @@ void HeaderSearch::loadSubdirectoryModul
     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)) {

Added: cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h?rev=346822&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h (added)
+++ cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h Tue Nov 13 17:08:03 2018
@@ -0,0 +1 @@
+int bar();

Added: cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map?rev=346822&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map (added)
+++ cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map Tue Nov 13 17:08:03 2018
@@ -0,0 +1,5 @@
+module ModuleInSubdir {
+header "h1.h"
+  export *
+}
+

Added: cfe/trunk/test/Modules/subdirectory-module-maps-working-dir.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/subdirectory-module-maps-working-dir.m?rev=346822&view=auto
==============================================================================
--- cfe/trunk/test/Modules/subdirectory-module-maps-working-dir.m (added)
+++ cfe/trunk/test/Modules/subdirectory-module-maps-working-dir.m Tue Nov 13 17:08:03 2018
@@ -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




More information about the cfe-commits mailing list