This method it a bit too large.
It is becoming inconvenient to update it.
This patch suggests a way to reduce and cleanup it.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| llvm/tools/obj2yaml/elf2yaml.cpp | ||
|---|---|---|
| 251 | std::function<...> is not needed. How about returning a pointer to class member function? | |
| llvm/tools/obj2yaml/elf2yaml.cpp | ||
|---|---|---|
| 251 | 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 *>`, | |
| llvm/tools/obj2yaml/elf2yaml.cpp | ||
|---|---|---|
| 251 | I see. C++ can't infer that the return type of a function type is covariant :( | |
std::function<...> is not needed. How about returning a pointer to class member function?