[PATCH] D69739: [llvm-objcopy][ELF] Add OriginalType & OriginalFlags

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 4 10:58:09 PST 2019


MaskRay added a comment.

In D69739#1731983 <https://reviews.llvm.org/D69739#1731983>, @jhenderson wrote:

> This seems like a good idea to me. It makes our classof results immutable after all, leading to a more robust program.
>
> One thought I had: did you consider adding just a new "Kind" enum instead, with the various kinds of sections recorded? That would add one field to the section class rather than two. I don't know if the Original* flags really have any other usage, and it would allow us to add further types later on which are not identified by flag/type whilst simplifying the classof functions to a basic comparison.


We are tackling an expression problem. `classof` member functions are indeed the only place that `OriginalType` and `OriginalFlag` are read. If we introduce `SectionBase::Kind` as a new member variable, we can avoid `OriginalType` and `OriginalFlag`, but the classof logic will have to be centralized in one place, because we need to initialize `Kind` when a section is created.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69739/new/

https://reviews.llvm.org/D69739





More information about the llvm-commits mailing list