[PATCH] D76499: [obj2yaml] - Simplify and reduce `ELFDumper<ELFT>::dumpSections`. NFCI.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 20 14:07:15 PDT 2020
grimar marked an inline comment as done.
grimar added inline comments.
================
Comment at: llvm/tools/obj2yaml/elf2yaml.cpp:251
+ auto GetDumper = [&, this](unsigned Type)
+ -> std::function<Expected<ELFYAML::Chunk *>(const Elf_Shdr *)> {
+ switch (Type) {
----------------
MaskRay wrote:
> std::function<...> is not needed. How about returning a pointer to class member function?
>
>
I wanted, but I do not think we can. The following will not compile:
```
typedef Expected<ELFYAML::Chunk *> (ELFDumper<ELFT>::*Fn)(const Elf_Shdr *);
auto GetDumper = [this](unsigned Type) -> Fn {
switch (Type) {
case ELF::SHT_DYNAMIC:
return &ELFDumper<ELFT>::dumpDynamicSection;
...
default:
return nullptr;
}
};
```
Because, for example, `dumpDynamicSection` returns `Expected<ELFYAML::DynamicSection*>` and not `Expected<ELFYAML::Chunk *>`. Other dumpers follows.
It seems can be fixed by changing return type of all dumper methods to ``Expected<ELFYAML::Chunk *>``,
but I am not sure it worth doing. `std::function` fits better here I think.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76499/new/
https://reviews.llvm.org/D76499
More information about the llvm-commits
mailing list