Skip to content

Commit f810cfc

Browse files
committed
[Serialization] Remove treatAsPartialModule parameter
This information can be derived from whether we're installing the module file into the main module.
1 parent c98c862 commit f810cfc

File tree

6 files changed

+20
-27
lines changed

6 files changed

+20
-27
lines changed

include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,13 @@ class SerializedModuleLoaderBase : public ModuleLoader {
149149
///
150150
/// If the AST cannot be loaded and \p diagLoc is present, a diagnostic is
151151
/// printed. (Note that \p diagLoc is allowed to be invalid.)
152-
FileUnit *loadAST(ModuleDecl &M, Optional<SourceLoc> diagLoc,
153-
StringRef moduleInterfacePath,
154-
std::unique_ptr<llvm::MemoryBuffer> moduleInputBuffer,
155-
std::unique_ptr<llvm::MemoryBuffer> moduleDocInputBuffer,
156-
std::unique_ptr<llvm::MemoryBuffer> moduleSourceInfoInputBuffer,
157-
bool isFramework, bool treatAsPartialModule);
152+
FileUnit *
153+
loadAST(ModuleDecl &M, Optional<SourceLoc> diagLoc,
154+
StringRef moduleInterfacePath,
155+
std::unique_ptr<llvm::MemoryBuffer> moduleInputBuffer,
156+
std::unique_ptr<llvm::MemoryBuffer> moduleDocInputBuffer,
157+
std::unique_ptr<llvm::MemoryBuffer> moduleSourceInfoInputBuffer,
158+
bool isFramework);
158159

159160
/// Check whether the module with a given name can be imported without
160161
/// importing it.

lib/Frontend/Frontend.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,7 @@ bool CompilerInstance::loadPartialModulesAndImplicitImports() {
839839
assert(PM.ModuleBuffer);
840840
if (!SML->loadAST(*MainModule, SourceLoc(), /*moduleInterfacePath*/"",
841841
std::move(PM.ModuleBuffer), std::move(PM.ModuleDocBuffer),
842-
std::move(PM.ModuleSourceInfoBuffer), /*isFramework*/false,
843-
/*treatAsPartialModule*/true))
842+
std::move(PM.ModuleSourceInfoBuffer), /*isFramework*/false))
844843
hadLoadError = true;
845844
}
846845
return hadLoadError;

lib/Serialization/ModuleFile.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,9 +1977,7 @@ ModuleFile::ModuleFile(
19771977
}
19781978
}
19791979

1980-
Status ModuleFile::associateWithFileContext(FileUnit *file,
1981-
SourceLoc diagLoc,
1982-
bool treatAsPartialModule) {
1980+
Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc) {
19831981
PrettyStackTraceModuleFile stackEntry(*this);
19841982

19851983
assert(!hasError() && "error already detected; should not call this");
@@ -2033,8 +2031,12 @@ Status ModuleFile::associateWithFileContext(FileUnit *file,
20332031
continue;
20342032
}
20352033

2034+
// If this module file is being installed into the main module, it's treated
2035+
// as a partial module.
2036+
auto isPartialModule = M->isMainModule();
2037+
20362038
if (dependency.isImplementationOnly() &&
2037-
!(treatAsPartialModule || ctx.LangOpts.DebuggerSupport)) {
2039+
!(isPartialModule || ctx.LangOpts.DebuggerSupport)) {
20382040
// When building normally (and not merging partial modules), we don't
20392041
// want to bring in the implementation-only module, because that might
20402042
// change the set of visible declarations. However, when debugging we

lib/Serialization/ModuleFile.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,14 +705,10 @@ class ModuleFile
705705
/// This does not include diagnostics about \e this file failing to load,
706706
/// but rather other things that might be imported as part of bringing the
707707
/// file into the AST.
708-
/// \param treatAsPartialModule If true, processes implementation-only
709-
/// information instead of assuming the client won't need it and shouldn't
710-
/// see it.
711708
///
712709
/// \returns any error that occurred during association, such as being
713710
/// compiled for a different OS.
714-
Status associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
715-
bool treatAsPartialModule);
711+
Status associateWithFileContext(FileUnit *file, SourceLoc diagLoc);
716712

717713
/// Transfers ownership of a buffer that might contain source code where
718714
/// other parts of the compiler could have emitted diagnostics, to keep them

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ FileUnit *SerializedModuleLoaderBase::loadAST(
651651
std::unique_ptr<llvm::MemoryBuffer> moduleInputBuffer,
652652
std::unique_ptr<llvm::MemoryBuffer> moduleDocInputBuffer,
653653
std::unique_ptr<llvm::MemoryBuffer> moduleSourceInfoInputBuffer,
654-
bool isFramework, bool treatAsPartialModule) {
654+
bool isFramework) {
655655
assert(moduleInputBuffer);
656656

657657
StringRef moduleBufferID = moduleInputBuffer->getBufferIdentifier();
@@ -688,8 +688,7 @@ FileUnit *SerializedModuleLoaderBase::loadAST(
688688

689689
auto diagLocOrInvalid = diagLoc.getValueOr(SourceLoc());
690690
loadInfo.status =
691-
loadedModuleFile->associateWithFileContext(fileUnit, diagLocOrInvalid,
692-
treatAsPartialModule);
691+
loadedModuleFile->associateWithFileContext(fileUnit, diagLocOrInvalid);
693692

694693
// FIXME: This seems wrong. Overlay for system Clang module doesn't
695694
// necessarily mean it's "system" module. User can make their own overlay
@@ -963,8 +962,7 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
963962

964963
if (!loadAST(*M, moduleID.Loc, moduleInterfacePathStr,
965964
std::move(moduleInputBuffer), std::move(moduleDocInputBuffer),
966-
std::move(moduleSourceInfoInputBuffer),
967-
isFramework, /*treatAsPartialModule*/false)) {
965+
std::move(moduleSourceInfoInputBuffer), isFramework)) {
968966
M->setFailedToLoad();
969967
}
970968

@@ -990,7 +988,6 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
990988
return nullptr;
991989

992990
bool isFramework = false;
993-
bool treatAsPartialModule = false;
994991
std::unique_ptr<llvm::MemoryBuffer> moduleInputBuffer;
995992
moduleInputBuffer = std::move(bufIter->second);
996993
MemoryBuffers.erase(bufIter);
@@ -1000,8 +997,7 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
1000997
SWIFT_DEFER { M->setHasResolvedImports(); };
1001998

1002999
if (!loadAST(*M, moduleID.Loc, /*moduleInterfacePath*/ "",
1003-
std::move(moduleInputBuffer), {}, {},
1004-
isFramework, treatAsPartialModule)) {
1000+
std::move(moduleInputBuffer), {}, {}, isFramework)) {
10051001
return nullptr;
10061002
}
10071003

tools/SourceKit/lib/SwiftLang/SwiftIndexing.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ static void indexModule(llvm::MemoryBuffer *Input,
186186
// correct filename here.
187187
auto FUnit = Loader->loadAST(*Mod, None, /*moduleInterfacePath*/"",
188188
std::move(Buf), nullptr, nullptr,
189-
/*isFramework*/false,
190-
/*treatAsPartialModule*/false);
189+
/*isFramework*/false);
191190

192191
// FIXME: Not knowing what went wrong is pretty bad. loadModule() should be
193192
// more modular, rather than emitting diagnostics itself.

0 commit comments

Comments
 (0)