[PATCH] D45166: [ELF] - Introduce helper for iterating over linker commands.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 3 09:27:37 PDT 2018


grimar added a comment.

In https://reviews.llvm.org/D45166#1054578, @ruiu wrote:

> I'm personally not too excited about this kind of higher-order function, and my first impression is that the original code is better. I might be convinced either way, but I think I'm mildly against doing this.


The original code is sometimes hard to read IMO. 
For example constructions like below are simplified greatly.

  for (BaseCommand *Base : SectionCommands) {
  auto *Sec = dyn_cast<OutputSection>(Base);
  if (!Sec)
   continue;

You do not need to think about what is `Base2` anymore:

  for (BaseCommand *Base2 : Sec->SectionCommands)
  if (auto *Cmd = dyn_cast<SymbolAssignment>(Base2))
    declareSymbol(Cmd);


https://reviews.llvm.org/D45166





More information about the llvm-commits mailing list