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