[PATCH] D71242: [LLD][ELF]{ARM][AArch64] Add missing classof to patch sections.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 18:09:52 PST 2019


ruiu added a comment.

In D71242#1778777 <https://reviews.llvm.org/D71242#1778777>, @MaskRay wrote:

> In D71242#1778767 <https://reviews.llvm.org/D71242#1778767>, @ruiu wrote:
>
> > classof is an LLVM's way of implementing a dynamic casting, and the code is idiomatic -- we almost always dispatch only by an enum field. So this could be a bit confusing to those who are expecting that idiomatic mechanism? I wonder if it is better to define a new function instead of overloading classof.
>
>
> We already have such a code pattern
>
>   class EhFrameSection final : public SyntheticSection {
>   public:
>     EhFrameSection();
>     void writeTo(uint8_t *buf) override;
>     void finalizeContents() override;
>     bool isNeeded() const override { return !sections.empty(); }
>     size_t getSize() const override { return size; }
>  
>     static bool classof(const SectionBase *d) {
>       return SyntheticSection::classof(d) && d->name == ".eh_frame";
>     }
>


Ah, that's true. Not sure if it's a good pattern, but it seems it doesn't cause a confusion, so I'm fine with that.


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

https://reviews.llvm.org/D71242





More information about the llvm-commits mailing list