<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 28, 2016 at 12:13 PM, Eugene Leviant <span dir="ltr"><<a href="mailto:evgeny.leviant@gmail.com" target="_blank">evgeny.leviant@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> If you add classof to one derived class, you want to define classof for all derived classes, otherwise it won't work.<br>
<br>
</span>AFAIK, this just means that you can't use LLVM casting for other<br>
classes in the hierarchy. But let's use static_cast for now.</blockquote><div><br></div><div>That's true for this case, but that's a violation of the contract of classof. If class A is a derived class of B, isa<A>(X) == true implies that isa<B>(X) == true.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
2016-10-28 21:52 GMT+03:00 Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>>:<br>
> On Fri, Oct 28, 2016 at 11:44 AM, Eugene Leviant <<a href="mailto:evgeny.leviant@gmail.com">evgeny.leviant@gmail.com</a>><br>
> wrote:<br>
>><br>
>> evgeny777 added a comment.<br>
>><br>
>> I have Sectio<br>
>><br>
>><br>
>><br>
>> ================<br>
>> Comment at: include/llvm/Object/<wbr>ELFObjectFile.h:99-101<br>
>> +  static inline bool classof(const SectionRef *v) {<br>
>> +    return v->getObject()->isELF();<br>
>> +  }<br>
>> ----------------<br>
>> ruiu wrote:<br>
>> > Why do you want this?<br>
>> I have SectionRef object and I want to get section offset, which is ELF<br>
>> section property.<br>
>> With this I can write:<br>
>><br>
>> ```<br>
>> cast<ELFSectionRef>(S)-><wbr>getOffset();<br>
>> ```<br>
>> Without it I have to use this one:<br>
>> ```<br>
>><br>
>> cast<ELFObjectFileBase>(S-><wbr>getObject())-><wbr>getSectionOffset(S-><wbr>getRawDataRefImpl());<br>
>> ```<br>
><br>
><br>
> If you add classof to one derived class, you want to define classof for all<br>
> derived classes, otherwise it won't work. If you already know the type of an<br>
> object, you can just do static_cast<>, can't you?<br>
</div></div></blockquote></div><br></div></div>