mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Serialization] Remove treatAsPartialModule parameter
This information can be derived from whether we're installing the module file into the main module.
This commit is contained in:
@@ -149,12 +149,13 @@ public:
|
||||
///
|
||||
/// If the AST cannot be loaded and \p diagLoc is present, a diagnostic is
|
||||
/// printed. (Note that \p diagLoc is allowed to be invalid.)
|
||||
FileUnit *loadAST(ModuleDecl &M, Optional<SourceLoc> diagLoc,
|
||||
StringRef moduleInterfacePath,
|
||||
std::unique_ptr<llvm::MemoryBuffer> moduleInputBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> moduleDocInputBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> moduleSourceInfoInputBuffer,
|
||||
bool isFramework, bool treatAsPartialModule);
|
||||
FileUnit *
|
||||
loadAST(ModuleDecl &M, Optional<SourceLoc> diagLoc,
|
||||
StringRef moduleInterfacePath,
|
||||
std::unique_ptr<llvm::MemoryBuffer> moduleInputBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> moduleDocInputBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> moduleSourceInfoInputBuffer,
|
||||
bool isFramework);
|
||||
|
||||
/// Check whether the module with a given name can be imported without
|
||||
/// importing it.
|
||||
|
||||
@@ -839,8 +839,7 @@ bool CompilerInstance::loadPartialModulesAndImplicitImports() {
|
||||
assert(PM.ModuleBuffer);
|
||||
if (!SML->loadAST(*MainModule, SourceLoc(), /*moduleInterfacePath*/"",
|
||||
std::move(PM.ModuleBuffer), std::move(PM.ModuleDocBuffer),
|
||||
std::move(PM.ModuleSourceInfoBuffer), /*isFramework*/false,
|
||||
/*treatAsPartialModule*/true))
|
||||
std::move(PM.ModuleSourceInfoBuffer), /*isFramework*/false))
|
||||
hadLoadError = true;
|
||||
}
|
||||
return hadLoadError;
|
||||
|
||||
@@ -1977,9 +1977,7 @@ ModuleFile::ModuleFile(
|
||||
}
|
||||
}
|
||||
|
||||
Status ModuleFile::associateWithFileContext(FileUnit *file,
|
||||
SourceLoc diagLoc,
|
||||
bool treatAsPartialModule) {
|
||||
Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc) {
|
||||
PrettyStackTraceModuleFile stackEntry(*this);
|
||||
|
||||
assert(!hasError() && "error already detected; should not call this");
|
||||
@@ -2033,8 +2031,12 @@ Status ModuleFile::associateWithFileContext(FileUnit *file,
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this module file is being installed into the main module, it's treated
|
||||
// as a partial module.
|
||||
auto isPartialModule = M->isMainModule();
|
||||
|
||||
if (dependency.isImplementationOnly() &&
|
||||
!(treatAsPartialModule || ctx.LangOpts.DebuggerSupport)) {
|
||||
!(isPartialModule || ctx.LangOpts.DebuggerSupport)) {
|
||||
// When building normally (and not merging partial modules), we don't
|
||||
// want to bring in the implementation-only module, because that might
|
||||
// change the set of visible declarations. However, when debugging we
|
||||
|
||||
@@ -705,14 +705,10 @@ public:
|
||||
/// This does not include diagnostics about \e this file failing to load,
|
||||
/// but rather other things that might be imported as part of bringing the
|
||||
/// file into the AST.
|
||||
/// \param treatAsPartialModule If true, processes implementation-only
|
||||
/// information instead of assuming the client won't need it and shouldn't
|
||||
/// see it.
|
||||
///
|
||||
/// \returns any error that occurred during association, such as being
|
||||
/// compiled for a different OS.
|
||||
Status associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
|
||||
bool treatAsPartialModule);
|
||||
Status associateWithFileContext(FileUnit *file, SourceLoc diagLoc);
|
||||
|
||||
/// Transfers ownership of a buffer that might contain source code where
|
||||
/// other parts of the compiler could have emitted diagnostics, to keep them
|
||||
|
||||
@@ -651,7 +651,7 @@ FileUnit *SerializedModuleLoaderBase::loadAST(
|
||||
std::unique_ptr<llvm::MemoryBuffer> moduleInputBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> moduleDocInputBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> moduleSourceInfoInputBuffer,
|
||||
bool isFramework, bool treatAsPartialModule) {
|
||||
bool isFramework) {
|
||||
assert(moduleInputBuffer);
|
||||
|
||||
StringRef moduleBufferID = moduleInputBuffer->getBufferIdentifier();
|
||||
@@ -688,8 +688,7 @@ FileUnit *SerializedModuleLoaderBase::loadAST(
|
||||
|
||||
auto diagLocOrInvalid = diagLoc.getValueOr(SourceLoc());
|
||||
loadInfo.status =
|
||||
loadedModuleFile->associateWithFileContext(fileUnit, diagLocOrInvalid,
|
||||
treatAsPartialModule);
|
||||
loadedModuleFile->associateWithFileContext(fileUnit, diagLocOrInvalid);
|
||||
|
||||
// FIXME: This seems wrong. Overlay for system Clang module doesn't
|
||||
// necessarily mean it's "system" module. User can make their own overlay
|
||||
@@ -963,8 +962,7 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
|
||||
|
||||
if (!loadAST(*M, moduleID.Loc, moduleInterfacePathStr,
|
||||
std::move(moduleInputBuffer), std::move(moduleDocInputBuffer),
|
||||
std::move(moduleSourceInfoInputBuffer),
|
||||
isFramework, /*treatAsPartialModule*/false)) {
|
||||
std::move(moduleSourceInfoInputBuffer), isFramework)) {
|
||||
M->setFailedToLoad();
|
||||
}
|
||||
|
||||
@@ -990,7 +988,6 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
|
||||
return nullptr;
|
||||
|
||||
bool isFramework = false;
|
||||
bool treatAsPartialModule = false;
|
||||
std::unique_ptr<llvm::MemoryBuffer> moduleInputBuffer;
|
||||
moduleInputBuffer = std::move(bufIter->second);
|
||||
MemoryBuffers.erase(bufIter);
|
||||
@@ -1000,8 +997,7 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
|
||||
SWIFT_DEFER { M->setHasResolvedImports(); };
|
||||
|
||||
if (!loadAST(*M, moduleID.Loc, /*moduleInterfacePath*/ "",
|
||||
std::move(moduleInputBuffer), {}, {},
|
||||
isFramework, treatAsPartialModule)) {
|
||||
std::move(moduleInputBuffer), {}, {}, isFramework)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,8 +186,7 @@ static void indexModule(llvm::MemoryBuffer *Input,
|
||||
// correct filename here.
|
||||
auto FUnit = Loader->loadAST(*Mod, None, /*moduleInterfacePath*/"",
|
||||
std::move(Buf), nullptr, nullptr,
|
||||
/*isFramework*/false,
|
||||
/*treatAsPartialModule*/false);
|
||||
/*isFramework*/false);
|
||||
|
||||
// FIXME: Not knowing what went wrong is pretty bad. loadModule() should be
|
||||
// more modular, rather than emitting diagnostics itself.
|
||||
|
||||
Reference in New Issue
Block a user