Skip to content

Commit 98ed31f

Browse files
committed
Make -import-underlying-module automatically export that module.
That's how everything behaved anyway. Might as well make it explicit and stop special-casing it. I've left in compatibility for modules built with older compilers so that people using the OS toolchains aren't immediately unable to debug their apps. As soon as we change the module format in a more significant way, I can take this out. Groundwork for rdar://problem/21254367; see next commit. Swift SVN r29437
1 parent 5d79c41 commit 98ed31f

File tree

7 files changed

+13
-20
lines changed

7 files changed

+13
-20
lines changed

include/swift/Serialization/ModuleFile.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ModuleFile : public LazyMemberLoader {
8585
const StringRef RawPath;
8686

8787
private:
88-
const unsigned IsExported : 1;
88+
unsigned IsExported : 1;
8989
const unsigned IsHeader : 1;
9090
const unsigned IsScoped : 1;
9191

@@ -109,6 +109,8 @@ class ModuleFile : public LazyMemberLoader {
109109
bool isHeader() const { return IsHeader; }
110110
bool isScoped() const { return IsScoped; }
111111

112+
void forceExported() { IsExported = true; }
113+
112114
std::string getPrettyPrintedPath() const;
113115
};
114116

@@ -307,6 +309,8 @@ class ModuleFile : public LazyMemberLoader {
307309
/// Whether this module file comes from a framework.
308310
unsigned IsFramework : 1;
309311

312+
/// THIS SETTING IS OBSOLETE BUT IS STILL USED BY OLDER MODULES.
313+
///
310314
/// Whether this module has a shadowed module that's part of its public
311315
/// interface.
312316
unsigned HasUnderlyingModule : 1;

include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ namespace input_block {
499499

500500
using ModuleFlagsLayout = BCRecordLayout<
501501
MODULE_FLAGS,
502-
BCFixed<1> // has underlying module?
502+
BCFixed<1> // has underlying module? [[UNUSED]]
503503
>;
504504

505505
using SearchPathLayout = BCRecordLayout<

include/swift/Serialization/SerializationOptions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ namespace swift {
3535
ArrayRef<std::string> ExtraClangOptions;
3636

3737
bool AutolinkForceLoad = false;
38-
bool HasUnderlyingModule = false;
3938
bool SerializeAllSIL = false;
4039
bool SerializeOptionsForDebugging = false;
4140
bool IsSIB = false;

lib/Frontend/Frontend.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ void CompilerInstance::performSema() {
298298
SmallVector<ImportPair, 4> additionalImports;
299299

300300
if (underlying)
301-
additionalImports.push_back({ { /*accessPath=*/{}, underlying }, {} });
301+
additionalImports.push_back({ { /*accessPath=*/{}, underlying },
302+
SourceFile::ImportFlags::Exported });
302303
if (importedHeaderModule)
303304
additionalImports.push_back({ { /*accessPath=*/{}, importedHeaderModule },
304305
SourceFile::ImportFlags::Exported });

lib/Serialization/ModuleFile.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,11 @@ Status ModuleFile::associateWithFileContext(FileUnit *file,
10671067
continue;
10681068
}
10691069

1070+
// This is for backwards-compatibility with modules that still rely on the
1071+
// "HasUnderlyingModule" flag.
1072+
if (Bits.HasUnderlyingModule && module == ShadowedModule)
1073+
dependency.forceExported();
1074+
10701075
if (scopePath.empty()) {
10711076
dependency.Import = { {}, module };
10721077
} else {
@@ -1082,9 +1087,6 @@ Status ModuleFile::associateWithFileContext(FileUnit *file,
10821087
return error(Status::MissingDependency);
10831088
}
10841089

1085-
if (Bits.HasUnderlyingModule)
1086-
(void)getModule(FileContext->getParentModule()->getName());
1087-
10881090
if (Bits.HasEntryPoint) {
10891091
FileContext->getParentModule()->registerEntryPointFile(FileContext,
10901092
SourceLoc(),
@@ -1171,24 +1173,14 @@ void ModuleFile::getImportedModules(
11711173
SmallVectorImpl<Module::ImportedModule> &results,
11721174
Module::ImportFilter filter) {
11731175
PrettyModuleFileDeserialization stackEntry(*this);
1174-
bool includeShadowedModule = (filter != Module::ImportFilter::Private &&
1175-
ShadowedModule && Bits.HasUnderlyingModule);
11761176

11771177
for (auto &dep : Dependencies) {
11781178
if (filter != Module::ImportFilter::All &&
11791179
(filter == Module::ImportFilter::Public) ^ dep.isExported())
11801180
continue;
11811181
assert(dep.isLoaded());
11821182
results.push_back(dep.Import);
1183-
1184-
// FIXME: Do we want a way to limit re-exports?
1185-
if (includeShadowedModule && dep.Import.first.empty() &&
1186-
dep.Import.second == ShadowedModule)
1187-
includeShadowedModule = false;
11881183
}
1189-
1190-
if (includeShadowedModule)
1191-
results.push_back({ {}, ShadowedModule });
11921184
}
11931185

11941186
void ModuleFile::getImportDecls(SmallVectorImpl<Decl *> &Results) {

lib/Serialization/Serialization.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,6 @@ void Serializer::writeInputBlock(const SerializationOptions &options) {
724724
LinkLibrary.emit(ScratchRecord, serialization::LibraryKind::Library,
725725
options.AutolinkForceLoad, options.ModuleLinkName);
726726
}
727-
728-
ModuleFlags.emit(ScratchRecord, options.HasUnderlyingModule);
729727
}
730728

731729
/// Translate AST default argument kind to the Serialization enum values, which

tools/driver/frontend_main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ static bool performCompile(CompilerInstance &Instance,
700700
Invocation.getClangImporterOptions().ExtraArgs;
701701
if (!IRGenOpts.ForceLoadSymbolName.empty())
702702
serializationOpts.AutolinkForceLoad = true;
703-
serializationOpts.HasUnderlyingModule = opts.ImportUnderlyingModule;
704703

705704
// Options contain information about the developer's computer,
706705
// so only serialize them if the module isn't going to be shipped to

0 commit comments

Comments
 (0)