[llvm-readobj] Update readobj to re-use parsing code.
llvm-readobj hand rolls some CodeView parsing code for string tables, so this patch updates it to re-use some of the newly introduced parsing code in LLVMDebugInfoCodeView. Differential Revision: https://reviews.llvm.org/D32772 llvm-svn: 302052
This commit is contained in:
@@ -18,17 +18,17 @@ using namespace llvm::codeview;
|
||||
|
||||
StringTableRef::StringTableRef() {}
|
||||
|
||||
Error StringTableRef::initialize(BinaryStreamReader &Reader) {
|
||||
return Reader.readStreamRef(Stream, Reader.bytesRemaining());
|
||||
Error StringTableRef::initialize(BinaryStreamRef Contents) {
|
||||
Stream = Contents;
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
StringRef StringTableRef::getString(uint32_t Offset) const {
|
||||
Expected<StringRef> StringTableRef::getString(uint32_t Offset) const {
|
||||
BinaryStreamReader Reader(Stream);
|
||||
Reader.setOffset(Offset);
|
||||
StringRef Result;
|
||||
Error EC = Reader.readCString(Result);
|
||||
assert(!EC);
|
||||
consumeError(std::move(EC));
|
||||
if (auto EC = Reader.readCString(Result))
|
||||
return std::move(EC);
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user