[lld] r277761 - [MachO] Factor out some common code in the Driver.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 4 12:56:26 PDT 2016
Author: davide
Date: Thu Aug 4 14:56:26 2016
New Revision: 277761
URL: http://llvm.org/viewvc/llvm-project?rev=277761&view=rev
Log:
[MachO] Factor out some common code in the Driver.
Modified:
lld/trunk/lib/Driver/DarwinLdDriver.cpp
Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=277761&r1=277760&r2=277761&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Thu Aug 4 14:56:26 2016
@@ -1137,6 +1137,18 @@ bool parse(llvm::ArrayRef<const char *>
return ctx.validate(diagnostics);
}
+static void createFiles(MachOLinkingContext &ctx, bool Implicit) {
+ std::vector<std::unique_ptr<File>> Files;
+ if (Implicit)
+ ctx.createImplicitFiles(Files);
+ else
+ ctx.createInternalFiles(Files);
+ for (auto i = Files.rbegin(), e = Files.rend(); i != e; ++i) {
+ auto &members = ctx.getNodes();
+ members.insert(members.begin(), llvm::make_unique<FileNode>(std::move(*i)));
+ }
+}
+
/// This is where the link is actually performed.
bool link(llvm::ArrayRef<const char *> args, raw_ostream &diagnostics) {
MachOLinkingContext ctx;
@@ -1151,20 +1163,10 @@ bool link(llvm::ArrayRef<const char *> a
if (FileNode *node = dyn_cast<FileNode>(ie.get()))
node->getFile()->parse();
- std::vector<std::unique_ptr<File>> internalFiles;
- ctx.createInternalFiles(internalFiles);
- for (auto i = internalFiles.rbegin(), e = internalFiles.rend(); i != e; ++i) {
- auto &members = ctx.getNodes();
- members.insert(members.begin(), llvm::make_unique<FileNode>(std::move(*i)));
- }
+ createFiles(ctx, false /* Implicit */);
- // Give target a chance to add files.
- std::vector<std::unique_ptr<File>> implicitFiles;
- ctx.createImplicitFiles(implicitFiles);
- for (auto i = implicitFiles.rbegin(), e = implicitFiles.rend(); i != e; ++i) {
- auto &members = ctx.getNodes();
- members.insert(members.begin(), llvm::make_unique<FileNode>(std::move(*i)));
- }
+ // Give target a chance to add files
+ createFiles(ctx, true /* Implicit */);
// Give target a chance to postprocess input files.
// Mach-O uses this chance to move all object files before library files.
More information about the llvm-commits
mailing list