@@ -1544,33 +1544,40 @@ void CompilerInstance::setMainModule(ModuleDecl *newMod) {
15441544 Context->MainModule = newMod;
15451545}
15461546
1547+ void CompilerInstance::loadAccessNotesIfNeeded () {
1548+ if (Invocation.getFrontendOptions ().AccessNotesPath .empty ())
1549+ return ;
1550+
1551+ auto *mainModule = getMainModule ();
1552+
1553+ auto accessNotesPath = Invocation.getFrontendOptions ().AccessNotesPath ;
1554+
1555+ auto bufferOrError =
1556+ swift::vfs::getFileOrSTDIN (getFileSystem (), accessNotesPath);
1557+ if (bufferOrError) {
1558+ int sourceID = SourceMgr.addNewSourceBuffer (std::move (bufferOrError.get ()));
1559+ auto buffer = SourceMgr.getLLVMSourceMgr ().getMemoryBuffer (sourceID);
1560+
1561+ if (auto accessNotesFile = AccessNotesFile::load (*Context, buffer))
1562+ mainModule->getAccessNotes () = *accessNotesFile;
1563+ } else {
1564+ Diagnostics.diagnose (SourceLoc (), diag::access_notes_file_io_error,
1565+ accessNotesPath, bufferOrError.getError ().message ());
1566+ }
1567+ }
1568+
15471569bool CompilerInstance::performParseAndResolveImportsOnly () {
15481570 FrontendStatsTracer tracer (getStatsReporter (), " parse-and-resolve-imports" );
15491571
1550- auto *mainModule = getMainModule ();
1572+ // NOTE: Do not add new logic to this function, use the request evaluator to
1573+ // lazily evaluate instead. Once the below computations are requestified we
1574+ // ought to be able to remove this function.
15511575
15521576 // Load access notes.
1553- if (!Invocation.getFrontendOptions ().AccessNotesPath .empty ()) {
1554- auto accessNotesPath = Invocation.getFrontendOptions ().AccessNotesPath ;
1555-
1556- auto bufferOrError =
1557- swift::vfs::getFileOrSTDIN (getFileSystem (), accessNotesPath);
1558- if (bufferOrError) {
1559- int sourceID =
1560- SourceMgr.addNewSourceBuffer (std::move (bufferOrError.get ()));
1561- auto buffer =
1562- SourceMgr.getLLVMSourceMgr ().getMemoryBuffer (sourceID);
1563-
1564- if (auto accessNotesFile = AccessNotesFile::load (*Context, buffer))
1565- mainModule->getAccessNotes () = *accessNotesFile;
1566- }
1567- else {
1568- Diagnostics.diagnose (SourceLoc (), diag::access_notes_file_io_error,
1569- accessNotesPath, bufferOrError.getError ().message ());
1570- }
1571- }
1577+ loadAccessNotesIfNeeded ();
15721578
15731579 // Resolve imports for all the source files in the module.
1580+ auto *mainModule = getMainModule ();
15741581 performImportResolution (mainModule);
15751582
15761583 bindExtensions (*mainModule);
0 commit comments