[lld] r264981 - Use Expected<T> instead of ErrorOr<T>in yaml reader. NFC
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 30 18:13:04 PDT 2016
Author: pete
Date: Wed Mar 30 20:13:04 2016
New Revision: 264981
URL: http://llvm.org/viewvc/llvm-project?rev=264981&view=rev
Log:
Use Expected<T> instead of ErrorOr<T>in yaml reader. NFC
Modified:
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
lld/trunk/unittests/MachOTests/MachONormalizedFileYAMLTests.cpp
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h?rev=264981&r1=264980&r2=264981&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h Wed Mar 30 20:13:04 2016
@@ -300,7 +300,7 @@ size_t headerAndLoadCommandsSize(const N
/// Parses a yaml encoded mach-o file to produce an in-memory normalized view.
-ErrorOr<std::unique_ptr<NormalizedFile>>
+llvm::Expected<std::unique_ptr<NormalizedFile>>
readYaml(std::unique_ptr<MemoryBuffer> &mb);
/// Writes a yaml encoded mach-o files given an in-memory normalized view.
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp?rev=264981&r1=264980&r2=264981&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp Wed Mar 30 20:13:04 2016
@@ -800,7 +800,7 @@ bool MachOYamlIOTaggedDocumentHandler::h
namespace normalized {
/// Parses a yaml encoded mach-o file to produce an in-memory normalized view.
-ErrorOr<std::unique_ptr<NormalizedFile>>
+llvm::Expected<std::unique_ptr<NormalizedFile>>
readYaml(std::unique_ptr<MemoryBuffer> &mb) {
// Make empty NormalizedFile.
std::unique_ptr<NormalizedFile> f(new NormalizedFile());
@@ -814,8 +814,9 @@ readYaml(std::unique_ptr<MemoryBuffer> &
yin >> *f;
// Return error if there were parsing problems.
- if (yin.error())
- return make_error_code(lld::YamlReaderError::illegal_value);
+ if (auto ec = yin.error())
+ return llvm::make_error<GenericError>(Twine("YAML parsing error: ")
+ + ec.message());
// Hand ownership of instantiated NormalizedFile to caller.
return std::move(f);
Modified: lld/trunk/unittests/MachOTests/MachONormalizedFileYAMLTests.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/MachOTests/MachONormalizedFileYAMLTests.cpp?rev=264981&r1=264980&r2=264981&view=diff
==============================================================================
--- lld/trunk/unittests/MachOTests/MachONormalizedFileYAMLTests.cpp (original)
+++ lld/trunk/unittests/MachOTests/MachONormalizedFileYAMLTests.cpp Wed Mar 30 20:13:04 2016
@@ -21,7 +21,7 @@ using lld::mach_o::normalized::Relocatio
static std::unique_ptr<NormalizedFile> fromYAML(StringRef str) {
std::unique_ptr<MemoryBuffer> mb(MemoryBuffer::getMemBuffer(str));
- ErrorOr<std::unique_ptr<NormalizedFile>> r
+ llvm::Expected<std::unique_ptr<NormalizedFile>> r
= lld::mach_o::normalized::readYaml(mb);
EXPECT_FALSE(!r);
return std::move(*r);
More information about the llvm-commits
mailing list