mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 08:36:07 +00:00
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:
parent
08462f7859
commit
81b030cbf6
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user