Skip to content

Commit 96fb3d6

Browse files
committed
[Module aliasing] Serialize binary with module real name
Resolves rdar://83632529
1 parent f189992 commit 96fb3d6

17 files changed

+200
-167
lines changed

include/swift/AST/FileUnit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class FileUnit : public DeclContext, public ASTAllocated<FileUnit> {
293293
/// Usually this is the module name itself, but certain Clang features allow
294294
/// substituting another name instead.
295295
virtual StringRef getExportedModuleName() const {
296-
return getParentModule()->getName().str();
296+
return getParentModule()->getRealName().str();
297297
}
298298

299299
/// Traverse the decls within this file.

lib/AST/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ StringRef ModuleDecl::ReverseFullNameIterator::operator*() const {
15011501
assert(current && "all name components exhausted");
15021502

15031503
if (auto *swiftModule = current.dyn_cast<const ModuleDecl *>())
1504-
return swiftModule->getName().str();
1504+
return swiftModule->getRealName().str();
15051505

15061506
auto *clangModule =
15071507
static_cast<const clang::Module *>(current.get<const void *>());

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3582,7 +3582,7 @@ StringRef ClangModuleUnit::getExportedModuleName() const {
35823582
if (clangModule && !clangModule->ExportAsModule.empty())
35833583
return clangModule->ExportAsModule;
35843584

3585-
return getParentModule()->getName().str();
3585+
return getParentModule()->getRealName().str();
35863586
}
35873587

35883588
ModuleDecl *ClangModuleUnit::getOverlayModule() const {

lib/Serialization/Serialization.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ IdentifierID Serializer::addModuleRef(const ModuleDecl *module) {
752752
if (module == this->M->getASTContext().TheBuiltinModule)
753753
return BUILTIN_MODULE_ID;
754754
auto moduleName =
755-
module->getASTContext().getIdentifier(module->getName().str());
755+
module->getASTContext().getIdentifier(module->getRealName().str());
756756
return addDeclBaseNameRef(moduleName);
757757
}
758758

@@ -961,7 +961,7 @@ void Serializer::writeHeader(const SerializationOptions &options) {
961961
control_block::RevisionLayout Revision(Out);
962962
control_block::IsOSSALayout IsOSSA(Out);
963963

964-
ModuleName.emit(ScratchRecord, M->getName().str());
964+
ModuleName.emit(ScratchRecord, M->getRealName().str());
965965

966966
SmallString<32> versionStringBuf;
967967
llvm::raw_svector_ostream versionString(versionStringBuf);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Lib
2+
3+
public func run() {
4+
Lib.start()
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import AppleLogging
2+
import Lib
3+
4+
public func run() {
5+
Lib.start()
6+
}
7+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Logging
2+
import Lib
3+
4+
public func run() {
5+
Lib.start()
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Logging
2+
3+
public func start() {
4+
Logging.setup()
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
public struct Logger {
2+
public init() {}
3+
}
4+
5+
public func setup() -> Logging.Logger? { return Logger()
6+
}

test/Frontend/load-module-with-alias-chained-simple.swift

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)