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