Make a few utility functions file-scoped.

makeErrorFile and parseMemberFiles are now used only in DarwinLdDriver.cpp.
This patch moves them to that file.

llvm-svn: 262423
This commit is contained in:
Rui Ueyama 2016-03-01 23:52:04 +00:00
parent 958e44b17d
commit 947648f502
4 changed files with 20 additions and 24 deletions

View File

@ -27,14 +27,8 @@
namespace lld {
class LinkingContext;
class CoreLinkingContext;
class MachOLinkingContext;
typedef std::vector<std::unique_ptr<File>> FileVector;
FileVector makeErrorFile(StringRef path, std::error_code ec);
FileVector parseMemberFiles(std::unique_ptr<File> File);
/// Base class for all Drivers.
class Driver {
protected:

View File

@ -72,6 +72,25 @@ public:
DarwinLdOptTable() : OptTable(infoTable) {}
};
static std::vector<std::unique_ptr<File>>
makeErrorFile(StringRef path, std::error_code ec) {
std::vector<std::unique_ptr<File>> result;
result.push_back(llvm::make_unique<ErrorFile>(path, ec));
return result;
}
static std::vector<std::unique_ptr<File>>
parseMemberFiles(std::unique_ptr<File> file) {
std::vector<std::unique_ptr<File>> members;
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;
}
std::vector<std::unique_ptr<File>>
loadFile(MachOLinkingContext &ctx, StringRef path,
raw_ostream &diag, bool wholeArchive, bool upwardDylib) {

View File

@ -29,23 +29,6 @@
namespace lld {
FileVector makeErrorFile(StringRef path, std::error_code ec) {
std::vector<std::unique_ptr<File>> result;
result.push_back(llvm::make_unique<ErrorFile>(path, ec));
return result;
}
FileVector parseMemberFiles(std::unique_ptr<File> file) {
std::vector<std::unique_ptr<File>> members;
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;
}
void Driver::parseLLVMOptions(const LinkingContext &ctx) {
// Honor -mllvm
if (!ctx.llvmOptions().empty()) {

View File

@ -219,7 +219,7 @@ private:
bool _logLoading;
std::vector<std::unique_ptr<MemoryBuffer>> _memberBuffers;
std::mutex _mutex;
FileVector _filesReturned;
std::vector<std::unique_ptr<File>> _filesReturned;
};
class ArchiveReader : public Reader {