Return ErrorOr from SymbolRef::getName.

This function can really fail since the string table offset can be out of
bounds.

Using ErrorOr makes sure the error is checked.

Hopefully a lot of the boilerplate code in tools/* can go away once we have
a diagnostic manager in Object.

llvm-svn: 241297
This commit is contained in:
Rafael Espindola
2015-07-02 20:55:21 +00:00
parent 4dc5adc731
commit 5d0c2ffadf
30 changed files with 244 additions and 168 deletions

View File

@@ -145,10 +145,13 @@ void COFFObjectFile::moveSymbolNext(DataRefImpl &Ref) const {
}
}
std::error_code COFFObjectFile::getSymbolName(DataRefImpl Ref,
StringRef &Result) const {
ErrorOr<StringRef> COFFObjectFile::getSymbolName(DataRefImpl Ref) const {
COFFSymbolRef Symb = getCOFFSymbol(Ref);
return getSymbolName(Symb, Result);
StringRef Result;
std::error_code EC = getSymbolName(Symb, Result);
if (EC)
return EC;
return Result;
}
uint64_t COFFObjectFile::getSymbolValue(DataRefImpl Ref) const {