COFF: Remove BitcodeFile::BitcodeFile(StringRef Filename).

In r238690, I made all files have only MemoryBufferRefs. This change
is to do the same thing for the bitcode file reader. Also updated
a few variable names to match with other code.

llvm-svn: 238782
This commit is contained in:
Rui Ueyama 2015-06-01 21:19:43 +00:00
parent 08462f7859
commit 81b030cbf6
3 changed files with 8 additions and 15 deletions

View File

@ -77,7 +77,7 @@ ErrorOr<std::unique_ptr<InputFile>> LinkerDriver::openFile(StringRef Path) {
if (Magic == file_magic::archive)
return std::unique_ptr<InputFile>(new ArchiveFile(MBRef));
if (Magic == file_magic::bitcode)
return std::unique_ptr<InputFile>(new BitcodeFile(Path));
return std::unique_ptr<InputFile>(new BitcodeFile(MBRef));
return std::unique_ptr<InputFile>(new ObjectFile(MBRef));
}

View File

@ -246,14 +246,9 @@ std::error_code ImportFile::parse() {
std::error_code BitcodeFile::parse() {
std::string Err;
if (!Filename.empty()) {
M.reset(LTOModule::createFromFile(Filename.c_str(), llvm::TargetOptions(),
Err));
} else {
M.reset(LTOModule::createFromBuffer(MBRef.getBufferStart(),
MBRef.getBufferSize(),
llvm::TargetOptions(), Err));
}
M.reset(LTOModule::createFromBuffer(MB.getBufferStart(),
MB.getBufferSize(),
llvm::TargetOptions(), Err));
if (!Err.empty()) {
llvm::errs() << Err << '\n';
return make_error_code(LLDError::BrokenFile);
@ -268,8 +263,8 @@ std::error_code BitcodeFile::parse() {
SymbolBodies.push_back(new (Alloc) DefinedBitcode(SymName));
}
}
return std::error_code();
}
} // namespace coff
} // namespace lld

View File

@ -162,10 +162,9 @@ private:
// Used for LTO.
class BitcodeFile : public InputFile {
public:
explicit BitcodeFile(StringRef S) : InputFile(BitcodeKind), Filename(S) {}
explicit BitcodeFile(MemoryBufferRef M) : InputFile(BitcodeKind), MBRef(M) {}
explicit BitcodeFile(MemoryBufferRef M) : InputFile(BitcodeKind), MB(M) {}
static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; }
StringRef getName() override { return Filename; }
StringRef getName() override { return MB.getBufferIdentifier(); }
std::vector<SymbolBody *> &getSymbols() override { return SymbolBodies; }
LTOModule *getModule() const { return M.get(); }
@ -174,8 +173,7 @@ public:
private:
std::error_code parse() override;
std::string Filename;
MemoryBufferRef MBRef;
MemoryBufferRef MB;
std::vector<SymbolBody *> SymbolBodies;
llvm::BumpPtrAllocator Alloc;
std::unique_ptr<LTOModule> M;