mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 23:23:38 -04:00
[TextAPI][elfabi] Make TBE handlers functions that return Errors
Since TBEHandler doesn't maintain state or otherwise have any need to be a class right now, the read and write functions have been moved out and turned into standalone functions. Additionally, the TBE read function has been updated to return an Expected value for better error handling. Tests have been updated to reflect these changes. Differential Revision: https://reviews.llvm.org/D55450 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348735 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -142,16 +142,17 @@ template <> struct MappingTraits<ELFStub> {
|
||||
} // end namespace yaml
|
||||
} // end namespace llvm
|
||||
|
||||
std::unique_ptr<ELFStub> TBEHandler::readFile(StringRef Buf) {
|
||||
Expected<std::unique_ptr<ELFStub>> elfabi::readTBEFromBuffer(StringRef Buf) {
|
||||
yaml::Input YamlIn(Buf);
|
||||
std::unique_ptr<ELFStub> Stub(new ELFStub());
|
||||
YamlIn >> *Stub;
|
||||
if (YamlIn.error())
|
||||
return nullptr;
|
||||
if (std::error_code Err = YamlIn.error())
|
||||
return createStringError(Err, "YAML failed reading as TBE");
|
||||
|
||||
return Stub;
|
||||
}
|
||||
|
||||
Error TBEHandler::writeFile(raw_ostream &OS, const ELFStub &Stub) {
|
||||
Error elfabi::writeTBEToOutputStream(raw_ostream &OS, const ELFStub &Stub) {
|
||||
yaml::Output YamlOut(OS, NULL, /*WrapColumn =*/0);
|
||||
|
||||
YamlOut << const_cast<ELFStub &>(Stub);
|
||||
|
||||
Reference in New Issue
Block a user