Jump through hoops to avoid adding a new Serialization -> clang::Module dependency.

This commit is contained in:
Doug Gregor
2017-09-15 14:42:36 -07:00
parent 21e34d78d8
commit fc20debc36
3 changed files with 21 additions and 7 deletions

View File

@@ -21,9 +21,9 @@
#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 "clang/Basic/Module.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/OnDiskHashTable.h"
@@ -1562,18 +1562,20 @@ void ModuleFile::loadExtensions(NominalTypeDecl *nominal) {
}
if (nominal->getParent()->isModuleScopeContext()) {
Identifier moduleName = nominal->getParentModule()->getName();
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 clangModule
= nominal->getParentModule()->findUnderlyingClangModule()) {
if (!clangModule->ExportAsModule.empty())
moduleName = getContext().getIdentifier(clangModule->ExportAsModule);
std::string exportedModuleName;
if (auto clangModuleUnit =
dyn_cast<ClangModuleUnit>(parentModule->getFiles().front())) {
exportedModuleName = clangModuleUnit->getExportedModuleName();
moduleName = exportedModuleName;
}
for (auto item : *iter) {
if (item.first != moduleName.str())
if (item.first != moduleName)
continue;
Expected<Decl *> declOrError = getDeclChecked(item.second);
if (!declOrError) {