Skip to content

Commit 1f66a27

Browse files
graydonjrose-apple
authored andcommitted
Factor out toolchains::Darwin::addLinkerInputArgs.
1 parent 19bfc57 commit 1f66a27

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

lib/Driver/DarwinToolChains.cpp

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,35 @@ static bool wantsObjCRuntime(const llvm::Triple &triple) {
221221
llvm_unreachable("unknown Darwin OS");
222222
}
223223

224+
void
225+
toolchains::Darwin::addLinkerInputArgs(InvocationInfo &II,
226+
const JobContext &context) const {
227+
ArgStringList &Arguments = II.Arguments;
228+
if (context.shouldUseInputFileList()) {
229+
Arguments.push_back("-filelist");
230+
Arguments.push_back(context.getTemporaryFilePath("inputs", "LinkFileList"));
231+
II.FilelistInfos.push_back({Arguments.back(), file_types::TY_Object,
232+
FilelistInfo::WhichFiles::Input});
233+
} else {
234+
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
235+
file_types::TY_Object);
236+
}
237+
238+
addInputsOfType(Arguments, context.InputActions, file_types::TY_Object);
239+
240+
if (context.OI.CompilerMode == OutputInfo::Mode::SingleCompile)
241+
addInputsOfType(Arguments, context.Inputs, context.Args,
242+
file_types::TY_SwiftModuleFile, "-add_ast_path");
243+
else
244+
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
245+
file_types::TY_SwiftModuleFile, "-add_ast_path");
246+
247+
// Add all .swiftmodule file inputs as arguments, preceded by the
248+
// "-add_ast_path" linker option.
249+
addInputsOfType(Arguments, context.InputActions,
250+
file_types::TY_SwiftModuleFile, "-add_ast_path");
251+
}
252+
224253
void
225254
toolchains::Darwin::addArgsToLinkARCLite(ArgStringList &Arguments,
226255
const JobContext &context) const {
@@ -452,29 +481,7 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
452481
InvocationInfo II = {LD};
453482
ArgStringList &Arguments = II.Arguments;
454483

455-
if (context.shouldUseInputFileList()) {
456-
Arguments.push_back("-filelist");
457-
Arguments.push_back(context.getTemporaryFilePath("inputs", "LinkFileList"));
458-
II.FilelistInfos.push_back({Arguments.back(), file_types::TY_Object,
459-
FilelistInfo::WhichFiles::Input});
460-
} else {
461-
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
462-
file_types::TY_Object);
463-
}
464-
465-
addInputsOfType(Arguments, context.InputActions, file_types::TY_Object);
466-
467-
if (context.OI.CompilerMode == OutputInfo::Mode::SingleCompile)
468-
addInputsOfType(Arguments, context.Inputs, context.Args,
469-
file_types::TY_SwiftModuleFile, "-add_ast_path");
470-
else
471-
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
472-
file_types::TY_SwiftModuleFile, "-add_ast_path");
473-
474-
// Add all .swiftmodule file inputs as arguments, preceded by the
475-
// "-add_ast_path" linker option.
476-
addInputsOfType(Arguments, context.InputActions,
477-
file_types::TY_SwiftModuleFile, "-add_ast_path");
484+
addLinkerInputArgs(II, context);
478485

479486
switch (job.getKind()) {
480487
case LinkKind::None:

lib/Driver/ToolChains.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ namespace toolchains {
2424
class LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain {
2525
protected:
2626

27+
void addLinkerInputArgs(InvocationInfo &II,
28+
const JobContext &context) const;
29+
2730
void addArgsToLinkARCLite(llvm::opt::ArgStringList &Arguments,
2831
const JobContext &context) const;
2932

0 commit comments

Comments
 (0)