Push Clang's "exported module name" notion up to Swift's FileUnit

It's a pretty obscure feature (and one we wish we didn't need), but
sometimes API is initially exposed through one module in order to
build another one, and we want the canonical presented name to be
something else. Push this concept into Swift's AST properly so that
other parts of the compiler stop having to know that this is a
Clang-specific special case.

No functionality change in this commit; will be used in the next
commit.
This commit is contained in:
Jordan Rose
2019-03-21 14:08:31 -07:00
parent 61d3b0d4ec
commit 93616cd49e
5 changed files with 36 additions and 37 deletions

View File

@@ -25,7 +25,6 @@
#include "swift/AST/USRGeneration.h"
#include "swift/Basic/Range.h"
#include "swift/ClangImporter/ClangImporter.h"
#include "swift/ClangImporter/ClangModule.h"
#include "swift/Serialization/BCReadingExtras.h"
#include "swift/Serialization/SerializedModuleLoader.h"
#include "llvm/ADT/StringExtras.h"
@@ -1842,15 +1841,8 @@ void ModuleFile::loadExtensions(NominalTypeDecl *nominal) {
}
if (nominal->getParent()->isModuleScopeContext()) {
auto parentModule = nominal->getParentModule();
StringRef moduleName = parentModule->getName().str();
// If the originating module is a private module whose interface is
// re-exported via public module, check the name of the public module.
if (auto clangModuleUnit =
dyn_cast<ClangModuleUnit>(parentModule->getFiles().front())) {
moduleName = clangModuleUnit->getExportedModuleName();
}
auto parentFile = cast<FileUnit>(nominal->getParent());
StringRef moduleName = parentFile->getExportedModuleName();
for (auto item : *iter) {
if (item.first != moduleName)