Object: Factor out the code for creating the irsymtab for an arbitrary bitcode file.
This code now lives in lib/Object. The idea is that it can now be reused by IRObjectFile among other things. Differential Revision: https://reviews.llvm.org/D31921 llvm-svn: 304958
This commit is contained in:
@@ -139,3 +139,26 @@ IRObjectFile::create(MemoryBufferRef Object, LLVMContext &Context) {
|
||||
return std::unique_ptr<IRObjectFile>(
|
||||
new IRObjectFile(*BCOrErr, std::move(Mods)));
|
||||
}
|
||||
|
||||
Expected<IRSymtabFile> object::readIRSymtab(MemoryBufferRef MBRef) {
|
||||
IRSymtabFile F;
|
||||
ErrorOr<MemoryBufferRef> BCOrErr =
|
||||
IRObjectFile::findBitcodeInMemBuffer(MBRef);
|
||||
if (!BCOrErr)
|
||||
return errorCodeToError(BCOrErr.getError());
|
||||
|
||||
Expected<std::vector<BitcodeModule>> BMsOrErr =
|
||||
getBitcodeModuleList(*BCOrErr);
|
||||
if (!BMsOrErr)
|
||||
return BMsOrErr.takeError();
|
||||
|
||||
Expected<irsymtab::FileContents> FCOrErr = irsymtab::readBitcode(*BMsOrErr);
|
||||
if (!FCOrErr)
|
||||
return FCOrErr.takeError();
|
||||
|
||||
F.Mods = std::move(*BMsOrErr);
|
||||
F.Symtab = std::move(FCOrErr->Symtab);
|
||||
F.Strtab = std::move(FCOrErr->Strtab);
|
||||
F.TheReader = std::move(FCOrErr->TheReader);
|
||||
return std::move(F);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user