diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-06-22 22:20:47 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-06-22 22:20:47 +0000 |
commit | 4dcc0f7da78882b0946f6f46ec6397dd566b4e72 (patch) | |
tree | a432b035848070109874192d06e66b79a9dd8ef6 | |
parent | 32f848c058d7690f9123160307957cb31cef4ce7 (diff) |
[modules] When building a module, if there are multiple matches for a header
file in the loaded module maps and one of them is from the current module,
that's the right match.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240350 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Lex/ModuleMap.cpp | 3 | ||||
-rw-r--r-- | test/Modules/Inputs/explicit-build-prefer-self/a.h | 2 | ||||
-rw-r--r-- | test/Modules/Inputs/explicit-build-prefer-self/b.h | 2 | ||||
-rw-r--r-- | test/Modules/Inputs/explicit-build-prefer-self/map | 2 | ||||
-rw-r--r-- | test/Modules/Inputs/explicit-build-prefer-self/x.h | 0 | ||||
-rw-r--r-- | test/Modules/explicit-build-prefer-self.cpp | 3 |
6 files changed, 12 insertions, 0 deletions
diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp index 075a17f68b..4ef0674f8d 100644 --- a/lib/Lex/ModuleMap.cpp +++ b/lib/Lex/ModuleMap.cpp @@ -346,6 +346,9 @@ ModuleMap::KnownHeader ModuleMap::findModuleForHeader(const FileEntry *File) { ModuleMap::KnownHeader Result; // Iterate over all modules that 'File' is part of to find the best fit. for (KnownHeader &H : Known->second) { + // Prefer a header from the current module over all others. + if (H.getModule() == CompilingModule) + return MakeResult(H); // Cannot use a module if it is unavailable. if (!H.getModule()->isAvailable()) continue; diff --git a/test/Modules/Inputs/explicit-build-prefer-self/a.h b/test/Modules/Inputs/explicit-build-prefer-self/a.h new file mode 100644 index 0000000000..d45761275d --- /dev/null +++ b/test/Modules/Inputs/explicit-build-prefer-self/a.h @@ -0,0 +1,2 @@ +// a +#include "x.h" diff --git a/test/Modules/Inputs/explicit-build-prefer-self/b.h b/test/Modules/Inputs/explicit-build-prefer-self/b.h new file mode 100644 index 0000000000..76e2042cb9 --- /dev/null +++ b/test/Modules/Inputs/explicit-build-prefer-self/b.h @@ -0,0 +1,2 @@ +// b +#include "x.h" diff --git a/test/Modules/Inputs/explicit-build-prefer-self/map b/test/Modules/Inputs/explicit-build-prefer-self/map new file mode 100644 index 0000000000..26be8e6907 --- /dev/null +++ b/test/Modules/Inputs/explicit-build-prefer-self/map @@ -0,0 +1,2 @@ +module a { header "a.h" header "x.h" } +module b { header "b.h" header "x.h" } diff --git a/test/Modules/Inputs/explicit-build-prefer-self/x.h b/test/Modules/Inputs/explicit-build-prefer-self/x.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/Modules/Inputs/explicit-build-prefer-self/x.h diff --git a/test/Modules/explicit-build-prefer-self.cpp b/test/Modules/explicit-build-prefer-self.cpp new file mode 100644 index 0000000000..aa2197995b --- /dev/null +++ b/test/Modules/explicit-build-prefer-self.cpp @@ -0,0 +1,3 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -emit-module -fmodule-name=a %S/Inputs/explicit-build-prefer-self/map -o a.pcm +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -emit-module -fmodule-name=b %S/Inputs/explicit-build-prefer-self/map -o b.pcm |