Move a function from Driver.cpp to InputFile.cpp.

This patch doesn't improve code per se, but it should make the following
patch's diff easier to read.

llvm-svn: 312170
This commit is contained in:
Rui Ueyama 2017-08-30 20:55:18 +00:00
parent 608df027fd
commit f59b709ae4
3 changed files with 21 additions and 19 deletions

View File

@ -522,25 +522,6 @@ static void parseModuleDefs(StringRef Path) {
}
}
std::vector<MemoryBufferRef> getArchiveMembers(Archive *File) {
std::vector<MemoryBufferRef> V;
Error Err = Error::success();
for (const ErrorOr<Archive::Child> &COrErr : File->children(Err)) {
Archive::Child C =
check(COrErr,
File->getFileName() + ": could not get the child of the archive");
MemoryBufferRef MBRef =
check(C.getMemoryBufferRef(),
File->getFileName() +
": could not get the buffer for a child of the archive");
V.push_back(MBRef);
}
if (Err)
fatal(File->getFileName() +
": Archive::children failed: " + toString(std::move(Err)));
return V;
}
// A helper function for filterBitcodeFiles.
static bool needsRebuilding(MemoryBufferRef MB) {
// The MSVC linker doesn't support thin archives, so if it's a thin

View File

@ -83,6 +83,25 @@ void ArchiveFile::addMember(const Archive::Symbol *Sym) {
Driver->enqueueArchiveMember(C, Sym->getName(), getName());
}
std::vector<MemoryBufferRef> getArchiveMembers(Archive *File) {
std::vector<MemoryBufferRef> V;
Error Err = Error::success();
for (const ErrorOr<Archive::Child> &COrErr : File->children(Err)) {
Archive::Child C =
check(COrErr,
File->getFileName() + ": could not get the child of the archive");
MemoryBufferRef MBRef =
check(C.getMemoryBufferRef(),
File->getFileName() +
": could not get the buffer for a child of the archive");
V.push_back(MBRef);
}
if (Err)
fatal(File->getFileName() +
": Archive::children failed: " + toString(std::move(Err)));
return V;
}
void ObjFile::parse() {
// Parse a memory buffer as a COFF file.
std::unique_ptr<Binary> Bin = check(createBinary(MB), toString(this));

View File

@ -31,6 +31,8 @@ class DbiModuleDescriptorBuilder;
namespace lld {
namespace coff {
std::vector<MemoryBufferRef> getArchiveMembers(llvm::object::Archive *File);
using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
using llvm::COFF::MachineTypes;
using llvm::object::Archive;