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

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 12:13:43 PDT 2016


> If you add classof to one derived class, you want to define classof for all derived classes, otherwise it won't work.

AFAIK, this just means that you can't use LLVM casting for other
classes in the hierarchy. But let's use static_cast for now.

2016-10-28 21:52 GMT+03:00 Rui Ueyama <ruiu at google.com>:
> 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?


More information about the llvm-commits mailing list