Skip to content

Commit 6cca050

Browse files
authored
[Serialization] Retire "shadowed module" in favor of "underlying" (swiftlang#24711)
Similar to 517f5d6, the "shadowed" terminology didn't end up describing the most common use of the feature; there is pretty much no intended case where a Swift module shadows a Clang module without also re-exporting it. Switch to "underlying", which was already in use in a few places, and which better parallels "overlay". No intended functionality change.
1 parent b903f71 commit 6cca050

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ ERROR(serialization_missing_dependencies,Fatal,
625625
ERROR(serialization_circular_dependency,Fatal,
626626
"circular dependency between modules '%0' and %1",
627627
(StringRef, Identifier))
628-
ERROR(serialization_missing_shadowed_module,Fatal,
628+
ERROR(serialization_missing_underlying_module,Fatal,
629629
"cannot load underlying module for %0", (Identifier))
630630
ERROR(serialization_name_mismatch,Fatal,
631631
"cannot load module '%0' as '%1'", (StringRef, StringRef))

include/swift/Serialization/ModuleFile.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class ModuleFile
5757
/// A reference back to the AST representation of the file.
5858
FileUnit *FileContext = nullptr;
5959

60-
/// The module shadowed by this module, if any.
61-
ModuleDecl *ShadowedModule = nullptr;
60+
/// The module that this module is an overlay of, if any.
61+
ModuleDecl *UnderlyingModule = nullptr;
6262

6363
/// The module file data.
6464
std::unique_ptr<llvm::MemoryBuffer> ModuleInputBuffer;
@@ -702,8 +702,8 @@ class ModuleFile
702702
return Dependencies;
703703
}
704704

705-
/// The module shadowed by this module, if any.
706-
ModuleDecl *getShadowedModule() const { return ShadowedModule; }
705+
/// The module that this module is an overlay for, if any.
706+
ModuleDecl *getUnderlyingModule() const { return UnderlyingModule; }
707707

708708
/// Searches the module's top-level decls for the given identifier.
709709
void lookupValue(DeclName name, SmallVectorImpl<ValueDecl*> &results);

include/swift/Serialization/Validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum class Status {
4343
MissingDependency,
4444

4545
/// The module file is an overlay for a Clang module, which can't be found.
46-
MissingShadowedModule,
46+
MissingUnderlyingModule,
4747

4848
/// The module file depends on a module that is still being loaded, i.e.
4949
/// there is a circular dependency.

lib/Serialization/Deserialization.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,14 +2010,14 @@ ModuleDecl *ModuleFile::getModule(ArrayRef<Identifier> name,
20102010
// FIXME: duplicated from NameBinder::getModule
20112011
if (name.size() == 1 &&
20122012
name.front() == FileContext->getParentModule()->getName()) {
2013-
if (!ShadowedModule && allowLoading) {
2013+
if (!UnderlyingModule && allowLoading) {
20142014
auto importer = getContext().getClangModuleLoader();
20152015
assert(importer && "no way to import shadowed module");
2016-
ShadowedModule = importer->loadModule(SourceLoc(),
2017-
{ { name.front(), SourceLoc() } });
2016+
UnderlyingModule = importer->loadModule(SourceLoc(),
2017+
{{name.front(), SourceLoc()}});
20182018
}
20192019

2020-
return ShadowedModule;
2020+
return UnderlyingModule;
20212021
}
20222022

20232023
SmallVector<ImportDecl::AccessPathElement, 4> importPath;

lib/Serialization/ModuleFile.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,10 +1570,10 @@ Status ModuleFile::associateWithFileContext(FileUnit *file,
15701570
}
15711571
auto module = getModule(modulePath, /*allowLoading*/true);
15721572
if (!module || module->failedToLoad()) {
1573-
// If we're missing the module we're shadowing, treat that specially.
1573+
// If we're missing the module we're an overlay for, treat that specially.
15741574
if (modulePath.size() == 1 &&
15751575
modulePath.front() == file->getParentModule()->getName()) {
1576-
return error(Status::MissingShadowedModule);
1576+
return error(Status::MissingUnderlyingModule);
15771577
}
15781578

15791579
// Otherwise, continue trying to load dependencies, so that we can list
@@ -1720,10 +1720,10 @@ TypeDecl *ModuleFile::lookupNestedType(Identifier name,
17201720
}
17211721
}
17221722

1723-
if (!ShadowedModule)
1723+
if (!UnderlyingModule)
17241724
return nullptr;
17251725

1726-
for (FileUnit *file : ShadowedModule->getFiles())
1726+
for (FileUnit *file : UnderlyingModule->getFiles())
17271727
if (auto *nestedType = file->lookupNestedType(name, parent))
17281728
return nestedType;
17291729

@@ -2195,8 +2195,8 @@ ModuleFile::getOpaqueReturnTypeDecls(SmallVectorImpl<OpaqueTypeDecl *> &results)
21952195
}
21962196

21972197
void ModuleFile::getDisplayDecls(SmallVectorImpl<Decl *> &results) {
2198-
if (ShadowedModule)
2199-
ShadowedModule->getDisplayDecls(results);
2198+
if (UnderlyingModule)
2199+
UnderlyingModule->getDisplayDecls(results);
22002200

22012201
PrettyStackTraceModuleFile stackEntry(*this);
22022202
getImportDecls(results);

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ FileUnit *SerializedModuleLoaderBase::loadAST(
562562
// necessarily mean it's "system" module. User can make their own overlay
563563
// in non-system directory.
564564
// Remove this block after we fix the test suite.
565-
if (auto shadowed = loadedModuleFile->getShadowedModule())
565+
if (auto shadowed = loadedModuleFile->getUnderlyingModule())
566566
if (shadowed->isSystemModule())
567567
M.setIsSystemModule(true);
568568

@@ -704,8 +704,8 @@ void swift::serialization::diagnoseSerializedASTLoadFailure(
704704
break;
705705
}
706706

707-
case serialization::Status::MissingShadowedModule: {
708-
Ctx.Diags.diagnose(diagLoc, diag::serialization_missing_shadowed_module,
707+
case serialization::Status::MissingUnderlyingModule: {
708+
Ctx.Diags.diagnose(diagLoc, diag::serialization_missing_underlying_module,
709709
ModuleName);
710710
if (Ctx.SearchPathOpts.SDKPath.empty() &&
711711
llvm::Triple(llvm::sys::getProcessTriple()).isMacOSX()) {
@@ -938,7 +938,7 @@ void SerializedASTFile::collectLinkLibraries(
938938
}
939939

940940
bool SerializedASTFile::isSystemModule() const {
941-
if (auto Mod = File.getShadowedModule()) {
941+
if (auto Mod = File.getUnderlyingModule()) {
942942
return Mod->isSystemModule();
943943
}
944944
return false;
@@ -1065,8 +1065,8 @@ StringRef SerializedASTFile::getFilename() const {
10651065
}
10661066

10671067
const clang::Module *SerializedASTFile::getUnderlyingClangModule() const {
1068-
if (auto *ShadowedModule = File.getShadowedModule())
1069-
return ShadowedModule->findUnderlyingClangModule();
1068+
if (auto *UnderlyingModule = File.getUnderlyingModule())
1069+
return UnderlyingModule->findUnderlyingClangModule();
10701070
return nullptr;
10711071
}
10721072

0 commit comments

Comments
 (0)