summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TextAPI/ELF/TBEHandler.cpp
diff options
context:
space:
mode:
authorArmando Montanez <amontanez@google.com>2018-12-10 02:36:33 +0000
committerArmando Montanez <amontanez@google.com>2018-12-10 02:36:33 +0000
commite353459549fe27d9c28e80166eb75c363dfa1726 (patch)
tree6a2a89a9590fc831cf7c6f7b95b4945732a05a39 /llvm/lib/TextAPI/ELF/TBEHandler.cpp
parent5cc8920d02e90e1a5ec2e1a740f0c7f1bd87002f (diff)
downloadbcm5719-llvm-e353459549fe27d9c28e80166eb75c363dfa1726.tar.gz
bcm5719-llvm-e353459549fe27d9c28e80166eb75c363dfa1726.zip
[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 llvm-svn: 348735
Diffstat (limited to 'llvm/lib/TextAPI/ELF/TBEHandler.cpp')
-rw-r--r--llvm/lib/TextAPI/ELF/TBEHandler.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/TextAPI/ELF/TBEHandler.cpp b/llvm/lib/TextAPI/ELF/TBEHandler.cpp
index 846f80a8b5b..426e7bb86e3 100644
--- a/llvm/lib/TextAPI/ELF/TBEHandler.cpp
+++ b/llvm/lib/TextAPI/ELF/TBEHandler.cpp
@@ -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);
OpenPOWER on IntegriCloud