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

@@ -169,10 +169,15 @@ collectASTModules(llvm::cl::list<std::string> &InputNames,
(ELF && Name == swift::ELFASTSectionName) ||
(COFF && Name == swift::COFFASTSectionName)) {
uint64_t Size = Section.getSize();
StringRef ContentsReference;
Section.getContents(ContentsReference);
llvm::Expected<llvm::StringRef> ContentsReference = Section.getContents();
if (!ContentsReference) {
llvm::outs() << "error: " << name << " "
<< errorToErrorCode(OF.takeError()).message() << "\n";
return false;
}
char *Module = Alloc.Allocate<char>(Size);
std::memcpy(Module, (void *)ContentsReference.begin(), Size);
std::memcpy(Module, (void *)ContentsReference->begin(), Size);
Modules.push_back({Module, Size});
}
}