@@ -1543,33 +1543,40 @@ void CompilerInstance::setMainModule(ModuleDecl *newMod) {
1543
1543
Context->MainModule = newMod;
1544
1544
}
1545
1545
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
+
1546
1568
bool CompilerInstance::performParseAndResolveImportsOnly () {
1547
1569
FrontendStatsTracer tracer (getStatsReporter (), " parse-and-resolve-imports" );
1548
1570
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.
1550
1574
1551
1575
// 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 ();
1571
1577
1572
1578
// Resolve imports for all the source files in the module.
1579
+ auto *mainModule = getMainModule ();
1573
1580
performImportResolution (mainModule);
1574
1581
1575
1582
bindExtensions (*mainModule);
0 commit comments