[PATCH] D92218: [llvm-readelf/obj] - Move unique warning handling logic to the `ObjDumper`.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 1 00:38:40 PST 2020
grimar added inline comments.
================
Comment at: llvm/tools/llvm-readobj/ObjDumper.cpp:43-44
+ handleAllErrors(std::move(Err), [&](const ErrorInfoBase &EI) {
+ cantFail(WarningHandler(EI.message()),
+ "WarningHandler should always return ErrorSuccess");
+ });
----------------
grimar wrote:
> jhenderson wrote:
> > Maybe we could simplify this by having `WarningHandler` not return an Error at all? What do you think?
> I'll take a look.
I think we can't do this, because this `WarningHandler` is used as argument to the API from ELF.h:
```
// This is a callback that can be passed to a number of functions.
// It can be used to ignore non-critical errors (warnings), which is
// useful for dumpers, like llvm-readobj.
// It accepts a warning message string and returns a success
// when the warning should be ignored or an error otherwise.
using WarningHandler = llvm::function_ref<Error(const Twine &Msg)>;
....
template <class ELFT>
Expected<StringRef>
ELFFile<ELFT>::getSectionName(const Elf_Shdr &Section,
WarningHandler WarnHandler) const {
auto SectionsOrErr = sections();
if (!SectionsOrErr)
return SectionsOrErr.takeError();
auto Table = getSectionStringTable(*SectionsOrErr, WarnHandler);
if (!Table)
return Table.takeError();
return getSectionName(Section, *Table);
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92218/new/
https://reviews.llvm.org/D92218
More information about the llvm-commits
mailing list