[PATCH] D26074: [ELF] Add getOffset to ELFSectionRef and enable LLVM casting for it

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 11:52:42 PDT 2016


On Fri, Oct 28, 2016 at 11:44 AM, Eugene Leviant <evgeny.leviant at gmail.com>
wrote:

> evgeny777 added a comment.
>
> I have Sectio
>
>
>
> ================
> Comment at: include/llvm/Object/ELFObjectFile.h:99-101
> +  static inline bool classof(const SectionRef *v) {
> +    return v->getObject()->isELF();
> +  }
> ----------------
> ruiu wrote:
> > Why do you want this?
> I have SectionRef object and I want to get section offset, which is ELF
> section property.
> With this I can write:
>
> ```
> cast<ELFSectionRef>(S)->getOffset();
> ```
> Without it I have to use this one:
> ```
> cast<ELFObjectFileBase>(S->getObject())->getSectionOffset(S->
> getRawDataRefImpl());
> ```


If you add classof to one derived class, you want to define classof for all
derived classes, otherwise it won't work. If you already know the type of
an object, you can just do static_cast<>, can't you?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161028/043fb57f/attachment.html>


More information about the llvm-commits mailing list