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