From: Davide Italiano Date: Thu, 4 Aug 2016 19:56:26 +0000 (+0000) Subject: [MachO] Factor out some common code in the Driver. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d62d116add5c9aa8427e810594508b3d8f4b6260;p=platform%2Fupstream%2Fllvm.git [MachO] Factor out some common code in the Driver. llvm-svn: 277761 --- diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp index f953669..8695e65 100644 --- a/lld/lib/Driver/DarwinLdDriver.cpp +++ b/lld/lib/Driver/DarwinLdDriver.cpp @@ -1137,6 +1137,18 @@ bool parse(llvm::ArrayRef args, MachOLinkingContext &ctx, return ctx.validate(diagnostics); } +static void createFiles(MachOLinkingContext &ctx, bool Implicit) { + std::vector> 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(std::move(*i))); + } +} + /// This is where the link is actually performed. bool link(llvm::ArrayRef args, raw_ostream &diagnostics) { MachOLinkingContext ctx; @@ -1151,20 +1163,10 @@ bool link(llvm::ArrayRef args, raw_ostream &diagnostics) { if (FileNode *node = dyn_cast(ie.get())) node->getFile()->parse(); - std::vector> 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(std::move(*i))); - } + createFiles(ctx, false /* Implicit */); - // Give target a chance to add files. - std::vector> 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(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.