@@ -299,10 +299,13 @@ static bool writeSIL(SILModule &SM, CompilerInstance &Instance,
299
299
opts.EmitSortedSIL );
300
300
}
301
301
302
- static bool printAsObjC (const std::string &outputPath, ModuleDecl *M,
303
- StringRef bridgingHeader, bool moduleIsPublic) {
302
+ static bool printAsObjCIfNeeded (const std::string &outputPath, ModuleDecl *M,
303
+ StringRef bridgingHeader, bool moduleIsPublic) {
304
304
using namespace llvm ::sys;
305
305
306
+ if (outputPath.empty ())
307
+ return false ;
308
+
306
309
clang::CompilerInstance Clang;
307
310
308
311
std::string tmpFilePath;
@@ -908,13 +911,13 @@ static bool performCompile(CompilerInstance &Instance,
908
911
909
912
// We've just been told to perform a typecheck, so we can return now.
910
913
if (Action == FrontendOptions::ActionType::Typecheck) {
911
- if (!opts. ObjCHeaderOutputPath . empty ())
912
- return printAsObjC (opts.ObjCHeaderOutputPath , Instance.getMainModule (),
913
- opts.ImplicitObjCHeaderPath , moduleIsPublic);
914
+ const bool hadPrintAsObjCError =
915
+ printAsObjCIfNeeded (opts.ObjCHeaderOutputPath , Instance.getMainModule (),
916
+ opts.ImplicitObjCHeaderPath , moduleIsPublic);
914
917
915
- return emitIndexDataIfNeeded (Instance. getPrimarySourceFile (), Invocation,
916
- Instance) ||
917
- Context.hadError ();
918
+ const bool hadEmitIndexDataError = emitIndexDataIfNeeded (
919
+ Instance. getPrimarySourceFile (), Invocation, Instance);
920
+ return hadPrintAsObjCError || hadEmitIndexDataError || Context.hadError ();
918
921
}
919
922
920
923
if (writeTBDIfNeeded (Invocation, Instance))
@@ -1236,10 +1239,8 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1236
1239
1237
1240
setPrivateDiscriminatorIfNeeded (IRGenOpts, MSF);
1238
1241
1239
- if (!opts.ObjCHeaderOutputPath .empty ()) {
1240
- (void )printAsObjC (opts.ObjCHeaderOutputPath , Instance.getMainModule (),
1241
- opts.ImplicitObjCHeaderPath , moduleIsPublic);
1242
- }
1242
+ (void )printAsObjCIfNeeded (opts.ObjCHeaderOutputPath , Instance.getMainModule (),
1243
+ opts.ImplicitObjCHeaderPath , moduleIsPublic);
1243
1244
1244
1245
if (Action == FrontendOptions::ActionType::EmitSIB)
1245
1246
return serializeSIBIfNeeded (Invocation.getFrontendOptions (), SM.get (),
0 commit comments