Skip to content

Commit 7d76ef9

Browse files
committed
[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
1 parent 6bdabcf commit 7d76ef9

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

clang/lib/Lex/HeaderSearch.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1638,8 +1638,10 @@ void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) {
16381638
return;
16391639

16401640
std::error_code EC;
1641+
SmallString<128> Dir = SearchDir.getDir()->getName();
1642+
FileMgr.makeAbsolutePath(Dir);
16411643
SmallString<128> DirNative;
1642-
llvm::sys::path::native(SearchDir.getDir()->getName(), DirNative);
1644+
llvm::sys::path::native(Dir, DirNative);
16431645
llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
16441646
for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
16451647
Dir != DirEnd && !EC; Dir.increment(EC)) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int bar();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module ModuleInSubdir {
2+
header "h1.h"
3+
export *
4+
}
5+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: rm -rf %t
2+
// RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t \
3+
// RUN: -working-directory %S/Inputs \
4+
// RUN: -I subdirectory-module-maps-working-dir \
5+
// RUN: %s -Werror=implicit-function-declaration -Xclang -verify
6+
7+
@import ModuleInSubdir;
8+
9+
void foo() {
10+
int x = bar();
11+
}
12+
13+
// expected-no-diagnostics

0 commit comments

Comments
 (0)