SectionRef::getContents() now returns Expected

Updated uses of object::SectionRef::getContents() since it now returns
an Expected<StringRef> instead of modifying the one it's passed.

See also: git-svn-id:
https://llvm.org/svn/llvm-project/llvm/trunk@360892
91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Gwen Mittertreiner
2019-05-17 17:56:17 -07:00
committed by Gwen Mittertreiner
parent dff6b6e258
commit 67cfef2d60
5 changed files with 43 additions and 23 deletions

View File

@@ -26,6 +26,7 @@
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/MachOUniversal.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#if defined(_WIN32)
#include <io.h>
@@ -137,11 +138,11 @@ public:
for (SectionRef S : O->sections()) {
if (!needToRelocate(S))
continue;
StringRef Content;
if (auto EC = S.getContents(Content))
reportError(EC);
std::memcpy(&Memory[getSectionAddress(S)], Content.data(),
Content.size());
llvm::Expected<llvm::StringRef> Content = S.getContents();
if (!Content)
reportError(errorToErrorCode(Content.takeError()));
std::memcpy(&Memory[getSectionAddress(S)], Content->data(),
Content->size());
}
}