From: Richard Smith Date: Fri, 10 Jul 2015 20:09:49 +0000 (+0000) Subject: [modules] Fix "prefer own module over others" rule when selecting a module for a... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24e9b5079a01bb126c06776c4fa0fd64246a435b;p=clang [modules] Fix "prefer own module over others" rule when selecting a module for a header to work in the presence of module hierarchy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241936 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp index e6fe38927e..6faae818bc 100644 --- a/lib/Lex/ModuleMap.cpp +++ b/lib/Lex/ModuleMap.cpp @@ -347,7 +347,7 @@ ModuleMap::KnownHeader ModuleMap::findModuleForHeader(const FileEntry *File) { // 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) + if (H.getModule()->getTopLevelModule() == CompilingModule) return MakeResult(H); // Cannot use a module if it is unavailable. if (!H.getModule()->isAvailable()) diff --git a/test/Modules/Inputs/explicit-build-prefer-self/map b/test/Modules/Inputs/explicit-build-prefer-self/map index 26be8e6907..042b2ae5b5 100644 --- a/test/Modules/Inputs/explicit-build-prefer-self/map +++ b/test/Modules/Inputs/explicit-build-prefer-self/map @@ -1,2 +1,2 @@ -module a { header "a.h" header "x.h" } -module b { header "b.h" header "x.h" } +module a { module h { header "a.h" } module x { header "x.h" } } +module b { module h { header "b.h" } module x { header "x.h" } }