Convert getSymbolSection to return an ErrorOr.

This function can actually fail since the symbol contains an index to the
section and that can be invalid.

llvm-svn: 244375
This commit is contained in:
Rafael Espindola
2015-08-07 23:27:14 +00:00
parent eeebc41b58
commit 8bab889b0f
22 changed files with 83 additions and 91 deletions

View File

@@ -98,8 +98,10 @@ void LLVMMoveToNextSection(LLVMSectionIteratorRef SI) {
void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect,
LLVMSymbolIteratorRef Sym) {
if (std::error_code ec = (*unwrap(Sym))->getSection(*unwrap(Sect)))
ErrorOr<section_iterator> SecOrErr = (*unwrap(Sym))->getSection();
if (std::error_code ec = SecOrErr.getError())
report_fatal_error(ec.message());
*unwrap(Sect) = *SecOrErr;
}
// ObjectFile Symbol iterators