@@ -1074,20 +1074,19 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
10741074 std::unique_ptr<SILModule> SM,
10751075 ModuleOrSourceFile MSF,
10761076 const PrimarySpecificPaths &PSPs,
1077- bool moduleIsPublic, int &ReturnValue,
1077+ int &ReturnValue,
10781078 FrontendObserver *observer);
10791079
1080- static bool
1081- performCompileStepsPostSema (const CompilerInvocation &Invocation,
1082- CompilerInstance &Instance,
1083- bool moduleIsPublic, int &ReturnValue,
1084- FrontendObserver *observer) {
1080+ static bool performCompileStepsPostSema (const CompilerInvocation &Invocation,
1081+ CompilerInstance &Instance,
1082+ int &ReturnValue,
1083+ FrontendObserver *observer) {
10851084 auto mod = Instance.getMainModule ();
10861085 if (auto SM = Instance.takeSILModule ()) {
10871086 const PrimarySpecificPaths PSPs =
10881087 Instance.getPrimarySpecificPathsForAtMostOnePrimary ();
10891088 return performCompileStepsPostSILGen (Instance, Invocation, std::move (SM),
1090- mod, PSPs, moduleIsPublic,
1089+ mod, PSPs,
10911090 ReturnValue, observer);
10921091 }
10931092
@@ -1100,7 +1099,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
11001099 const PrimarySpecificPaths PSPs =
11011100 Instance.getPrimarySpecificPathsForWholeModuleOptimizationMode ();
11021101 return performCompileStepsPostSILGen (Instance, Invocation, std::move (SM),
1103- mod, PSPs, moduleIsPublic,
1102+ mod, PSPs,
11041103 ReturnValue, observer);
11051104 }
11061105 // If there are primary source files, build a separate SILModule for
@@ -1113,7 +1112,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
11131112 const PrimarySpecificPaths PSPs =
11141113 Instance.getPrimarySpecificPathsForSourceFile (*PrimaryFile);
11151114 result |= performCompileStepsPostSILGen (Instance, Invocation, std::move (SM),
1116- PrimaryFile, PSPs, moduleIsPublic,
1115+ PrimaryFile, PSPs,
11171116 ReturnValue, observer);
11181117 }
11191118
@@ -1131,7 +1130,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
11311130 const PrimarySpecificPaths &PSPs =
11321131 Instance.getPrimarySpecificPathsForPrimary (SASTF->getFilename ());
11331132 result |= performCompileStepsPostSILGen (Instance, Invocation, std::move (SM),
1134- mod, PSPs, moduleIsPublic,
1133+ mod, PSPs,
11351134 ReturnValue, observer);
11361135 }
11371136 }
@@ -1158,8 +1157,7 @@ emitIndexData(const CompilerInvocation &Invocation, const CompilerInstance &Inst
11581157// / `-typecheck`, but skipped for any mode that runs SIL diagnostics if there's
11591158// / an error found there (to get those diagnostics back to the user faster).
11601159static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs (
1161- CompilerInstance &Instance, const CompilerInvocation &Invocation,
1162- bool moduleIsPublic) {
1160+ CompilerInstance &Instance, const CompilerInvocation &Invocation) {
11631161 const FrontendOptions &opts = Invocation.getFrontendOptions ();
11641162
11651163 // Record whether we failed to emit any of these outputs, but keep going; one
@@ -1182,7 +1180,8 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
11821180 }
11831181 hadAnyError |= printAsObjCIfNeeded (
11841182 Invocation.getObjCHeaderOutputPathForAtMostOnePrimary (),
1185- Instance.getMainModule (), BridgingHeaderPathForPrint, moduleIsPublic);
1183+ Instance.getMainModule (), BridgingHeaderPathForPrint,
1184+ Invocation.isModuleExternallyConsumed (Instance.getMainModule ()));
11861185 }
11871186
11881187 if (opts.InputsAndOutputs .hasModuleInterfaceOutputPath ()) {
@@ -1315,13 +1314,6 @@ static bool performCompile(CompilerInstance &Instance,
13151314 (void )emitLoadedModuleTraceForAllPrimariesIfNeeded (
13161315 Instance.getMainModule (), Instance.getDependencyTracker (), opts);
13171316
1318- // FIXME: This is still a lousy approximation of whether the module file will
1319- // be externally consumed.
1320- bool moduleIsPublic =
1321- !Instance.getMainModule ()->hasEntryPoint () &&
1322- opts.ImplicitObjCHeaderPath .empty () &&
1323- !Context.LangOpts .EnableAppExtensionRestrictions ;
1324-
13251317 // We've just been told to perform a typecheck, so we can return now.
13261318 if (Action == FrontendOptions::ActionType::Typecheck) {
13271319 if (emitIndexData (Invocation, Instance))
@@ -1336,8 +1328,7 @@ static bool performCompile(CompilerInstance &Instance,
13361328 // guarding the emission of whole-module supplementary outputs.
13371329 if (opts.InputsAndOutputs .isWholeModule ()) {
13381330 if (emitAnyWholeModulePostTypeCheckSupplementaryOutputs (Instance,
1339- Invocation,
1340- moduleIsPublic)) {
1331+ Invocation)) {
13411332 return true ;
13421333 }
13431334 }
@@ -1347,8 +1338,8 @@ static bool performCompile(CompilerInstance &Instance,
13471338 assert (FrontendOptions::doesActionGenerateSIL (Action) &&
13481339 " All actions not requiring SILGen must have been handled!" );
13491340
1350- return performCompileStepsPostSema (Invocation, Instance, moduleIsPublic ,
1351- ReturnValue, observer);
1341+ return performCompileStepsPostSema (Invocation, Instance, ReturnValue ,
1342+ observer);
13521343}
13531344
13541345static bool serializeSIB (SILModule *SM, const PrimarySpecificPaths &PSPs,
@@ -1575,9 +1566,8 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
15751566 std::unique_ptr<SILModule> SM,
15761567 ModuleOrSourceFile MSF,
15771568 const PrimarySpecificPaths &PSPs,
1578- bool moduleIsPublic, int &ReturnValue,
1569+ int &ReturnValue,
15791570 FrontendObserver *observer) {
1580-
15811571 FrontendOptions opts = Invocation.getFrontendOptions ();
15821572 FrontendOptions::ActionType Action = opts.RequestedAction ;
15831573 const ASTContext &Context = Instance.getASTContext ();
@@ -1618,7 +1608,7 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
16181608 return ;
16191609
16201610 SerializationOptions serializationOpts =
1621- Invocation.computeSerializationOptions (outs, moduleIsPublic );
1611+ Invocation.computeSerializationOptions (outs, Instance. getMainModule () );
16221612 serialize (MSF, serializationOpts, SM.get ());
16231613 };
16241614
@@ -1633,8 +1623,7 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
16331623 if (observer)
16341624 observer->performedSILProcessing (*SM);
16351625
1636- emitAnyWholeModulePostTypeCheckSupplementaryOutputs (Instance, Invocation,
1637- moduleIsPublic);
1626+ emitAnyWholeModulePostTypeCheckSupplementaryOutputs (Instance, Invocation);
16381627
16391628 if (Action == FrontendOptions::ActionType::EmitSIB)
16401629 return serializeSIB (SM.get (), PSPs, Context, MSF);
0 commit comments