@@ -815,6 +815,7 @@ static void emitIndexData(const CompilerInstance &Instance) {
815
815
// / anything past type-checking.
816
816
static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs (
817
817
CompilerInstance &Instance) {
818
+ const auto &Context = Instance.getASTContext ();
818
819
const auto &Invocation = Instance.getInvocation ();
819
820
const FrontendOptions &opts = Invocation.getFrontendOptions ();
820
821
@@ -833,7 +834,8 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
833
834
// failure does not mean skipping the rest.
834
835
bool hadAnyError = false ;
835
836
836
- if (opts.InputsAndOutputs .hasObjCHeaderOutputPath ()) {
837
+ if ((!Context.hadError () || opts.AllowModuleWithCompilerErrors ) &&
838
+ opts.InputsAndOutputs .hasObjCHeaderOutputPath ()) {
837
839
std::string BridgingHeaderPathForPrint;
838
840
if (!opts.ImplicitObjCHeaderPath .empty ()) {
839
841
if (opts.BridgingHeaderDirForPrint .hasValue ()) {
@@ -853,6 +855,11 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
853
855
Invocation.isModuleExternallyConsumed (Instance.getMainModule ()));
854
856
}
855
857
858
+ // Only want the header if there's been any errors, ie. there's not much
859
+ // point outputting a swiftinterface for an invalid module
860
+ if (Context.hadError ())
861
+ return hadAnyError;
862
+
856
863
if (opts.InputsAndOutputs .hasModuleInterfaceOutputPath ()) {
857
864
hadAnyError |= printModuleInterfaceIfNeeded (
858
865
Invocation.getModuleInterfaceOutputPathForWholeModule (),
@@ -995,9 +1002,10 @@ static void performEndOfPipelineActions(CompilerInstance &Instance) {
995
1002
996
1003
dumpAPIIfNeeded (Instance);
997
1004
}
998
- if (!ctx.hadError () || opts.AllowModuleWithCompilerErrors ) {
999
- emitAnyWholeModulePostTypeCheckSupplementaryOutputs (Instance);
1000
- }
1005
+
1006
+ // Contains the hadError checks internally, we still want to output the
1007
+ // Objective-C header when there's errors and currently allowing them
1008
+ emitAnyWholeModulePostTypeCheckSupplementaryOutputs (Instance);
1001
1009
1002
1010
// Verify reference dependencies of the current compilation job. Note this
1003
1011
// must be run *before* verifying diagnostics so that the former can be tested
0 commit comments