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

@@ -1225,8 +1225,9 @@ void llvm::PrintSymbolTable(const ObjectFile *o) {
uint64_t Address = *AddressOrError;
SymbolRef::Type Type = Symbol.getType();
uint32_t Flags = Symbol.getFlags();
section_iterator Section = o->section_end();
error(Symbol.getSection(Section));
ErrorOr<section_iterator> SectionOrErr = Symbol.getSection();
error(SectionOrErr.getError());
section_iterator Section = *SectionOrErr;
StringRef Name;
if (Type == SymbolRef::ST_Debug && Section != o->section_end()) {
Section->getName(Name);