<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hi Alex,<br>
</p>
<br>
<div class="moz-cite-prefix">On 02/14/17 04:23 AM, Alex L via
cfe-dev wrote:<br>
</div>
<blockquote
cite="mid:CAKS3GBtj=HhtwLSAnKp_fjcCzia9umWQxWvpv15JpzwWeP+TQA@mail.gmail.com"
type="cite">
<div dir="ltr">Hi Vladimir,
<div><br>
</div>
<div>It looks to me that this is a bug. However, it currently
seems to works because <span
style="font-size:12.800000190734863px">ObjCInterfaceLocInfo
is initialized through ObjCObjectTypeLoc so </span><span
style="font-size:12.800000190734863px">ObjCObjectTypeLocInfo</span><span
style="font-size:12.800000190734863px"> is valid, and after
that we initialize </span><span
style="font-size:12.800000190734863px">ObjCInterfaceTypeLocInfo.
</span></div>
</div>
</blockquote>
Are you sure, that this is valid? All *Loc classes memory
initialization is done through TypeSourceInfo which prepares memory
of corresponding size for TypeLoc data
(clang::ASTContext::CreateTypeSourceInfo).<br>
So for <span style="font-size:12.800000190734863px">ObjCInterfaceLoc
when TypeLoc::getFullDataSizeForType does the calculation =>
LocalData size is sizeof(</span><span
style="font-size:12.800000190734863px">ObjCInterfaceLocInfo)
(counted in ConcreteTypeLoc::getLocalDataSize) and </span><span
style="font-size:12.800000190734863px">ObjCObjectTypeLoc is not
asked about it's LocalData size => when call methods of </span><span
style="font-size:12.800000190734863px"></span><span
style="font-size:12.800000190734863px">ObjCObjectTypeLoc it casts
TypeLoc::Data to </span><span
style="font-size:12.800000190734863px"></span><span
style="font-size:12.800000190734863px">ObjCObjectTypeLocInfo</span><span
style="font-size:12.800000190734863px"> which was not allocated
properly (except memory for the 2 first fields which we get from </span><span
style="font-size:12.800000190734863px"><span
style="font-size:12.800000190734863px"></span><span
style="font-size:12.800000190734863px">ObjCInterfaceLocInfo)</span>.<br>
<br>
</span><br>
<blockquote
cite="mid:CAKS3GBtj=HhtwLSAnKp_fjcCzia9umWQxWvpv15JpzwWeP+TQA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><span style="font-size:12.800000190734863px">I guess that
we don't really see the effect of the bug because we don't
have tests that check for conflict between the name location
from ObjCInterfaceTypeLocInfo and left angle/right angle
locations from ObjCObjectTypeLoc. <br>
</span></div>
</div>
</blockquote>
So may be <span style="font-size:12.800000190734863px">there is no
need in inheritance and it should be as simple as.<br>
</span>class ObjCInterfaceTypeLoc : public
ConcreteTypeLoc<**UnqualTypeLoc**,<br>
ObjCInterfaceTypeLoc,<br>
ObjCInterfaceType,<br>
ObjCInterfaceLocInfo> {<br>
<br>
<blockquote
cite="mid:CAKS3GBtj=HhtwLSAnKp_fjcCzia9umWQxWvpv15JpzwWeP+TQA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><span style="font-size:12.800000190734863px">I think that
it would make sense for ObjCInterfaceTypeLoc to derive from </span><span
style="font-size:12.800000190734863px">ObjCObjectTypeLoc
directly.</span><span style="font-size:12.800000190734863px"> I'll
try to</span><span style="font-size:12.800000190734863px"> clean
it up.</span></div>
</div>
</blockquote>
I thought for inheritance you need same-structured LocInfo and use
InheritingConcreteTypeLoc<br>
<br>
Vladimir.<br>
<br>
<blockquote
cite="mid:CAKS3GBtj=HhtwLSAnKp_fjcCzia9umWQxWvpv15JpzwWeP+TQA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><span style="font-size:12.800000190734863px"><br>
</span></div>
<div><span style="font-size:12.800000190734863px">Alex</span></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 12 February 2017 at 16:34, Vladimir
Voskresensky via cfe-dev <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello
Clang experts,<br>
<br>
Could you help me, please, to understand how does
ObjCInterfaceTypeLoc class suppose to work?<br>
ObjCInterfaceTypeLoc is the only one class in TypeLoc
hierarchy which inherits twice from ConcreteTypeLoc.<br>
I see in source code and visually at<br>
<a moz-do-not-send="true"
href="http://ftp.llvm.org/doxygen/classclang_1_1ObjCInterfaceTypeLoc.html"
rel="noreferrer" target="_blank">http://ftp.llvm.org/doxygen/cl<wbr>assclang_1_1ObjCInterfaceTypeL<wbr>oc.html</a><br>
<br>
It is derived from ObjCObjectTypeLoc (which uses
ObjCObjectTypeLocInfo),<br>
but has own ObjCInterfaceLocInfo (passed as LocalData).<br>
Does it replace the ObjCObjectTypeLocInfo used by
ObjCObjectTypeLoc?<br>
ObjCInterfaceLocInfo is not derived from
ObjCObjectTypeLocInfo, so sizeof(ObjCInterfaceLocInfo) <
sizeof(ObjCObjectTypeLocInfo)<br>
How methods of ObjCObjectTypeLoc can work for
ObjCInterfaceTypeLoc instance?<br>
Shouldn't it be more like:<br>
<a moz-do-not-send="true"
href="http://clang.llvm.org/doxygen/classclang_1_1TypeofLikeTypeLoc.html"
rel="noreferrer" target="_blank">http://clang.llvm.org/doxygen/<wbr>classclang_1_1TypeofLikeTypeLo<wbr>c.html</a><br>
<br>
<br>
Thanks!<br>
Vladimir.<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a moz-do-not-send="true"
href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a moz-do-not-send="true"
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>