[lld] r235751 - Simplify parseMemberFiles to take a single file.
Rafael Espindola
rafael.espindola at gmail.com
Fri Apr 24 12:08:52 PDT 2015
Author: rafael
Date: Fri Apr 24 14:08:51 2015
New Revision: 235751
URL: http://llvm.org/viewvc/llvm-project?rev=235751&view=rev
Log:
Simplify parseMemberFiles to take a single file.
Modified:
lld/trunk/include/lld/Driver/Driver.h
lld/trunk/lib/Driver/DarwinLdDriver.cpp
lld/trunk/lib/Driver/Driver.cpp
Modified: lld/trunk/include/lld/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/Driver.h?rev=235751&r1=235750&r2=235751&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/Driver.h (original)
+++ lld/trunk/include/lld/Driver/Driver.h Fri Apr 24 14:08:51 2015
@@ -35,7 +35,7 @@ class ELFLinkingContext;
typedef std::vector<std::unique_ptr<File>> FileVector;
FileVector makeErrorFile(StringRef path, std::error_code ec);
-FileVector parseMemberFiles(FileVector &files);
+FileVector parseMemberFiles(std::unique_ptr<File> File);
FileVector loadFile(LinkingContext &ctx, StringRef path, bool wholeArchive);
/// Base class for all Drivers.
Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=235751&r1=235750&r2=235751&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Fri Apr 24 14:08:51 2015
@@ -93,10 +93,10 @@ loadFile(MachOLinkingContext &ctx, Strin
ctx.registerDylib(reinterpret_cast<mach_o::MachODylibFile *>(shl),
upwardDylib);
}
+ if (wholeArchive)
+ return parseMemberFiles(std::move(file));
std::vector<std::unique_ptr<File>> files;
files.push_back(std::move(file));
- if (wholeArchive)
- return parseMemberFiles(files);
return files;
}
Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=235751&r1=235750&r2=235751&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Fri Apr 24 14:08:51 2015
@@ -36,15 +36,13 @@ FileVector makeErrorFile(StringRef path,
return result;
}
-FileVector parseMemberFiles(FileVector &files) {
+FileVector parseMemberFiles(std::unique_ptr<File> file) {
std::vector<std::unique_ptr<File>> members;
- for (std::unique_ptr<File> &file : files) {
- if (auto *archive = dyn_cast<ArchiveLibraryFile>(file.get())) {
- if (std::error_code ec = archive->parseAllMembers(members))
- return makeErrorFile(file->path(), ec);
- } else {
- members.push_back(std::move(file));
- }
+ if (auto *archive = dyn_cast<ArchiveLibraryFile>(file.get())) {
+ if (std::error_code ec = archive->parseAllMembers(members))
+ return makeErrorFile(file->path(), ec);
+ } else {
+ members.push_back(std::move(file));
}
return members;
}
@@ -58,10 +56,11 @@ FileVector loadFile(LinkingContext &ctx,
ctx.registry().loadFile(std::move(mb.get()));
if (std::error_code ec = fileOrErr.getError())
return makeErrorFile(path, ec);
- std::vector<std::unique_ptr<File>> files;
- files.push_back(std::move(fileOrErr.get()));
+ std::unique_ptr<File> &file = fileOrErr.get();
if (wholeArchive)
- return parseMemberFiles(files);
+ return parseMemberFiles(std::move(file));
+ std::vector<std::unique_ptr<File>> files;
+ files.push_back(std::move(file));
return files;
}
More information about the llvm-commits
mailing list