Merge pull request #84225 from hamishknight/access-noted

Requestify the loading of access notes
This commit is contained in:
Hamish Knight
2025-09-13 12:06:43 +01:00
committed by GitHub
18 changed files with 311 additions and 236 deletions

View File

@@ -1564,28 +1564,6 @@ void CompilerInstance::setMainModule(ModuleDecl *newMod) {
Context->MainModule = newMod;
}
void CompilerInstance::loadAccessNotesIfNeeded() {
if (Invocation.getFrontendOptions().AccessNotesPath.empty())
return;
auto *mainModule = getMainModule();
auto accessNotesPath = Invocation.getFrontendOptions().AccessNotesPath;
auto bufferOrError =
swift::vfs::getFileOrSTDIN(getFileSystem(), accessNotesPath);
if (bufferOrError) {
int sourceID = SourceMgr.addNewSourceBuffer(std::move(bufferOrError.get()));
auto buffer = SourceMgr.getLLVMSourceMgr().getMemoryBuffer(sourceID);
if (auto accessNotesFile = AccessNotesFile::load(*Context, buffer))
mainModule->getAccessNotes() = *accessNotesFile;
} else {
Diagnostics.diagnose(SourceLoc(), diag::access_notes_file_io_error,
accessNotesPath, bufferOrError.getError().message());
}
}
bool CompilerInstance::performParseAndResolveImportsOnly() {
FrontendStatsTracer tracer(getStatsReporter(), "parse-and-resolve-imports");
@@ -1593,9 +1571,6 @@ bool CompilerInstance::performParseAndResolveImportsOnly() {
// lazily evaluate instead. Once the below computations are requestified we
// ought to be able to remove this function.
// Load access notes.
loadAccessNotesIfNeeded();
// Resolve imports for all the source files in the module.
auto *mainModule = getMainModule();
performImportResolution(mainModule);