Skip to content

Commit 679c6ae

Browse files
committed
Allow for both generating an ObjC header & emitting index data.
1 parent d3f1622 commit 679c6ae

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,13 @@ static bool writeSIL(SILModule &SM, CompilerInstance &Instance,
299299
opts.EmitSortedSIL);
300300
}
301301

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) {
304304
using namespace llvm::sys;
305305

306+
if (outputPath.empty())
307+
return false;
308+
306309
clang::CompilerInstance Clang;
307310

308311
std::string tmpFilePath;
@@ -908,13 +911,13 @@ static bool performCompile(CompilerInstance &Instance,
908911

909912
// We've just been told to perform a typecheck, so we can return now.
910913
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);
914917

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();
918921
}
919922

920923
if (writeTBDIfNeeded(Invocation, Instance))
@@ -1236,10 +1239,8 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
12361239

12371240
setPrivateDiscriminatorIfNeeded(IRGenOpts, MSF);
12381241

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);
12431244

12441245
if (Action == FrontendOptions::ActionType::EmitSIB)
12451246
return serializeSIBIfNeeded(Invocation.getFrontendOptions(), SM.get(),

0 commit comments

Comments
 (0)