[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 

llvm-svn: 346822
This commit is contained in:
Alex Lorenz 2018-11-14 01:08:03 +00:00
parent 6bdabcf368
commit 7d76ef9b3d
4 changed files with 22 additions and 1 deletions

View File

@ -1638,8 +1638,10 @@ void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) {
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)) {

View File

@ -0,0 +1,5 @@
module ModuleInSubdir {
header "h1.h"
export *
}

View File

@ -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
@import ModuleInSubdir;
void foo() {
int x = bar();
}
// expected-no-diagnostics