@@ -509,7 +509,7 @@ static bool writeSIL(SILModule &SM, ModuleDecl *M, bool EmitVerboseSIL,
509
509
}
510
510
511
511
static bool writeSIL (SILModule &SM, const PrimarySpecificPaths &PSPs,
512
- CompilerInstance &Instance,
512
+ const CompilerInstance &Instance,
513
513
const CompilerInvocation &Invocation) {
514
514
const FrontendOptions &opts = Invocation.getFrontendOptions ();
515
515
return writeSIL (SM, Instance.getMainModule (), opts.EmitVerboseSIL ,
@@ -640,10 +640,10 @@ static void debugFailWithCrash() {
640
640
// / \return true on error.
641
641
static bool emitIndexDataIfNeeded (SourceFile *PrimarySourceFile,
642
642
const CompilerInvocation &Invocation,
643
- CompilerInstance &Instance);
643
+ const CompilerInstance &Instance);
644
644
645
645
static void countStatsOfSourceFile (UnifiedStatsReporter &Stats,
646
- CompilerInstance &Instance,
646
+ const CompilerInstance &Instance,
647
647
SourceFile *SF) {
648
648
auto &C = Stats.getFrontendCounters ();
649
649
auto &SM = Instance.getSourceMgr ();
@@ -724,7 +724,7 @@ createOptRecordFile(StringRef Filename, DiagnosticEngine &DE) {
724
724
}
725
725
726
726
static bool precompileBridgingHeader (const CompilerInvocation &Invocation,
727
- CompilerInstance &Instance) {
727
+ const CompilerInstance &Instance) {
728
728
auto clangImporter = static_cast <ClangImporter *>(
729
729
Instance.getASTContext ().getClangModuleLoader ());
730
730
auto &ImporterOpts = Invocation.getClangImporterOptions ();
@@ -743,7 +743,7 @@ static bool precompileBridgingHeader(const CompilerInvocation &Invocation,
743
743
}
744
744
745
745
static bool precompileClangModule (const CompilerInvocation &Invocation,
746
- CompilerInstance &Instance) {
746
+ const CompilerInstance &Instance) {
747
747
auto clangImporter = static_cast <ClangImporter *>(
748
748
Instance.getASTContext ().getClangModuleLoader ());
749
749
return clangImporter->emitPrecompiledModule (
@@ -755,7 +755,7 @@ static bool precompileClangModule(const CompilerInvocation &Invocation,
755
755
}
756
756
757
757
static bool dumpPrecompiledClangModule (const CompilerInvocation &Invocation,
758
- CompilerInstance &Instance) {
758
+ const CompilerInstance &Instance) {
759
759
auto clangImporter = static_cast <ClangImporter *>(
760
760
Instance.getASTContext ().getClangModuleLoader ());
761
761
return clangImporter->dumpPrecompiledModule (
@@ -835,7 +835,7 @@ static void verifyGenericSignaturesIfNeeded(const CompilerInvocation &Invocation
835
835
}
836
836
837
837
static void dumpAndPrintScopeMap (const CompilerInvocation &Invocation,
838
- CompilerInstance &Instance, SourceFile *SF) {
838
+ const CompilerInstance &Instance, SourceFile *SF) {
839
839
// Not const because may require reexpansion
840
840
ASTScope &scope = SF->getScope ();
841
841
@@ -854,7 +854,7 @@ static void dumpAndPrintScopeMap(const CompilerInvocation &Invocation,
854
854
}
855
855
856
856
static SourceFile *getPrimaryOrMainSourceFile (const CompilerInvocation &Invocation,
857
- CompilerInstance &Instance) {
857
+ const CompilerInstance &Instance) {
858
858
SourceFile *SF = Instance.getPrimarySourceFile ();
859
859
if (!SF) {
860
860
SourceFileKind Kind = Invocation.getSourceFileKind ();
@@ -963,7 +963,7 @@ static void emitReferenceDependenciesForAllPrimaryInputsIfNeeded(
963
963
}
964
964
static void
965
965
emitSwiftRangesForAllPrimaryInputsIfNeeded (const CompilerInvocation &Invocation,
966
- CompilerInstance &Instance) {
966
+ const CompilerInstance &Instance) {
967
967
if (Invocation.getFrontendOptions ().InputsAndOutputs .hasSwiftRangesPath () &&
968
968
Instance.getPrimarySourceFiles ().empty ()) {
969
969
Instance.getASTContext ().Diags .diagnose (
@@ -981,7 +981,7 @@ emitSwiftRangesForAllPrimaryInputsIfNeeded(const CompilerInvocation &Invocation,
981
981
}
982
982
static void
983
983
emitCompiledSourceForAllPrimaryInputsIfNeeded (const CompilerInvocation &Invocation,
984
- CompilerInstance &Instance) {
984
+ const CompilerInstance &Instance) {
985
985
if (Invocation.getFrontendOptions ()
986
986
.InputsAndOutputs .hasCompiledSourcePath () &&
987
987
Instance.getPrimarySourceFiles ().empty ()) {
@@ -1158,7 +1158,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
1158
1158
1159
1159
// / Emits index data for all primary inputs, or the main module.
1160
1160
static bool
1161
- emitIndexData (const CompilerInvocation &Invocation, CompilerInstance &Instance) {
1161
+ emitIndexData (const CompilerInvocation &Invocation, const CompilerInstance &Instance) {
1162
1162
bool hadEmitIndexDataError = false ;
1163
1163
if (Instance.getPrimarySourceFiles ().empty ())
1164
1164
return emitIndexDataIfNeeded (nullptr , Invocation, Instance);
@@ -1344,7 +1344,7 @@ static bool performCompile(CompilerInstance &Instance,
1344
1344
}
1345
1345
1346
1346
static bool serializeSIB (SILModule *SM, const PrimarySpecificPaths &PSPs,
1347
- ASTContext &Context, ModuleOrSourceFile MSF) {
1347
+ const ASTContext &Context, ModuleOrSourceFile MSF) {
1348
1348
const std::string &moduleOutputPath =
1349
1349
PSPs.SupplementaryOutputs .ModuleOutputPath ;
1350
1350
assert (!moduleOutputPath.empty () && " must have an output path" );
@@ -1399,7 +1399,8 @@ static bool processCommandLineAndRunImmediately(const CompilerInvocation &Invoca
1399
1399
: MSF.get <ModuleDecl *>()->getModuleFilename ());
1400
1400
1401
1401
ReturnValue =
1402
- RunImmediately (Instance, CmdLine, IRGenOpts, Invocation.getSILOptions ());
1402
+ RunImmediately (Instance, CmdLine, IRGenOpts, Invocation.getSILOptions (),
1403
+ std::move (SM));
1403
1404
return Instance.getASTContext ().hadError ();
1404
1405
}
1405
1406
@@ -1492,7 +1493,7 @@ static bool performCompileStepsPostSILGen(
1492
1493
1493
1494
FrontendOptions opts = Invocation.getFrontendOptions ();
1494
1495
FrontendOptions::ActionType Action = opts.RequestedAction ;
1495
- ASTContext &Context = Instance.getASTContext ();
1496
+ const ASTContext &Context = Instance.getASTContext ();
1496
1497
const SILOptions &SILOpts = Invocation.getSILOptions ();
1497
1498
const IRGenOptions &IRGenOpts = Invocation.getIRGenOptions ();
1498
1499
@@ -1512,7 +1513,7 @@ static bool performCompileStepsPostSILGen(
1512
1513
}
1513
1514
1514
1515
if (Action == FrontendOptions::ActionType::EmitSIBGen) {
1515
- serializeSIB (SM.get (), PSPs, Instance. getASTContext () , MSF);
1516
+ serializeSIB (SM.get (), PSPs, Context , MSF);
1516
1517
return Context.hadError ();
1517
1518
}
1518
1519
@@ -1556,7 +1557,7 @@ static bool performCompileStepsPostSILGen(
1556
1557
moduleIsPublic);
1557
1558
1558
1559
if (Action == FrontendOptions::ActionType::EmitSIB)
1559
- return serializeSIB (SM.get (), PSPs, Instance. getASTContext () , MSF);
1560
+ return serializeSIB (SM.get (), PSPs, Context , MSF);
1560
1561
1561
1562
{
1562
1563
if (PSPs.haveModuleOrModuleDocOutputPaths ()) {
@@ -1643,7 +1644,7 @@ static bool performCompileStepsPostSILGen(
1643
1644
1644
1645
static bool emitIndexDataIfNeeded (SourceFile *PrimarySourceFile,
1645
1646
const CompilerInvocation &Invocation,
1646
- CompilerInstance &Instance) {
1647
+ const CompilerInstance &Instance) {
1647
1648
const FrontendOptions &opts = Invocation.getFrontendOptions ();
1648
1649
1649
1650
if (opts.IndexStorePath .empty ())
0 commit comments