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