<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><base href="x-msg://745/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Given that this is legal:</div><div><br></div><div><blockquote type="cite">const static int x = 0;</blockquote><br></div><div>...you're probably going to have to replace the whole declaration anyway.</div><div><br></div><div>Jordan</div><div><br></div><br><div><div>On Mar 21, 2013, at 6:35 , "Vane, Edwin" <<a href="mailto:edwin.vane@intel.com">edwin.vane@intel.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="WordSection1" style="page: WordSection1; "><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">I’ve continued to play with this problem in my spare time. I really believe there’s some necessary missing information somewhere.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">So instead of replacing parts of the decl specifier with ‘auto’, leaving cv qualifiers behind, I went the route of simply replacing the decl specifier to avoid the problem of not being able to identify where the CV qualifiers are and what they’re attached to. The problem now is I can’t tell where the decl specifier begins or ends. Decl::getLocStart() will point to the start of the declaration but that appears to be all I get. Given the following:<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">const MyType * const ptr = <init>;<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Decl::getLocStart() points to start of first const but not exactly ideal since this presumably would point to the start of other things in the decl specifier I don’t want to replace: storage specifiers and the like.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">DeclaratorDecl::getTypeSpecStartLoc() points to MyType despite the name implying it should point to the start of the type specifier which should be the start of the first const.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">This is a similar problem to the TypeSourceInfo missing the leading const. I know that QualifiedTypeLoc intentionally doesn’t provide source locations for the qualifiers but surely it should include the qualifiers in the range for the qualified type it represents? This still seems a deficiency to me. Could you point out the error in my understanding and/or point me at a function that properly points to the start of the type specifier?<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Finally, how does one find the *<b>end</b>* of the type specifier? I realize for types like function pointers, etc the end might be after the declarator id but I need to know the end of the range to replace.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(181, 196, 223); padding: 3pt 0in 0in; "><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; ">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; "><span class="Apple-converted-space"> </span>Vane, Edwin<span class="Apple-converted-space"> </span><br><b>Sent:</b><span class="Apple-converted-space"> </span>Thursday, March 14, 2013 12:52 PM<br><b>To:</b><span class="Apple-converted-space"> </span>Vane, Edwin; Richard Smith<br><b>Cc:</b><span class="Apple-converted-space"> </span>Clang Dev List (<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>)<br><b>Subject:</b><span class="Apple-converted-space"> </span>RE: [cfe-dev] Missing info from TypeLoc?<o:p></o:p></span></div></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">It occurred to me that perhaps the best way to handle my problem is just to get the type info of the Decl from looking at Type hierarchy and just replace the whole declaration specifier instead of trying to replace parts of it. As Manuel pointed out earlier, things like function pointer and member pointer types will break with TypeLoc because the identifier is buried in the type definition.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(181, 196, 223); padding: 3pt 0in 0in; "><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; ">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; "><span class="Apple-converted-space"> </span><a href="mailto:cfe-dev-bounces@cs.uiuc.edu" style="color: purple; text-decoration: underline; ">cfe-dev-bounces@cs.uiuc.edu</a><span class="Apple-converted-space"> </span>[<a href="mailto:cfe-dev-bounces@cs.uiuc.edu" style="color: purple; text-decoration: underline; ">mailto:cfe-dev-bounces@cs.uiuc.edu</a>]<span class="Apple-converted-space"> </span><b>On Behalf Of<span class="Apple-converted-space"> </span></b>Vane, Edwin<br><b>Sent:</b><span class="Apple-converted-space"> </span>Thursday, March 14, 2013 12:00 AM<br><b>To:</b><span class="Apple-converted-space"> </span>Richard Smith<br><b>Cc:</b><span class="Apple-converted-space"> </span>Clang Dev List (<a href="mailto:cfe-dev@cs.uiuc.edu" style="color: purple; text-decoration: underline; ">cfe-dev@cs.uiuc.edu</a>)<br><b>Subject:</b><span class="Apple-converted-space"> </span>Re: [cfe-dev] Missing info from TypeLoc?<o:p></o:p></span></div></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">I’m writing a tool to replace some part of the declaration with the ‘auto’ type specifier in the specific instance where a CXXNewExpr is the initializer. So like:<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">MyType *a = new MyType()<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">My problem is the handling of odd cases like:<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Const MyType *a = new MyType(); -> const auto *a = new MyType();<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Const MyType *a = new const MyType(); -> auto a = new const MyType();<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Mytype * const a = new MyType(); -> const auto a = new MyType();<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">// And so on<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Really what I need is a way of locating the cv-qualifier and what it applies to so I can replace as much or as little with ‘auto’ as necessary. I was using TypeLoc to get the location information for the replacement but I need something more complex now.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; ">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; "><span class="Apple-converted-space"> </span><a href="mailto:metafoo@gmail.com" style="color: purple; text-decoration: underline; ">metafoo@gmail.com</a><span class="Apple-converted-space"> </span>[<a href="mailto:metafoo@gmail.com" style="color: purple; text-decoration: underline; ">mailto:metafoo@gmail.com</a>]<span class="Apple-converted-space"> </span><b>On Behalf Of<span class="Apple-converted-space"> </span></b>Richard Smith<br><b>Sent:</b><span class="Apple-converted-space"> </span>Wednesday, March 13, 2013 4:04 PM<br><b>To:</b><span class="Apple-converted-space"> </span>Vane, Edwin<br><b>Cc:</b><span class="Apple-converted-space"> </span>Clang Dev List (<a href="mailto:cfe-dev@cs.uiuc.edu" style="color: purple; text-decoration: underline; ">cfe-dev@cs.uiuc.edu</a>)<br><b>Subject:</b><span class="Apple-converted-space"> </span>Re: [cfe-dev] Missing info from TypeLoc?<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">On Wed, Mar 13, 2013 at 6:27 AM, Vane, Edwin <<a href="mailto:edwin.vane@intel.com" target="_blank" style="color: purple; text-decoration: underline; ">edwin.vane@intel.com</a>> wrote:<o:p></o:p></div><div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin: 5pt 0in 5pt 4.8pt; "><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Is there an API I can re-use to parse the specifiers or at least get me part of the way toward what I need?</span><o:p></o:p></div></blockquote><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">What is it that you need? :)<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "> <o:p></o:p></div></div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin: 5pt 0in 5pt 4.8pt; "><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; ">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; "><span class="Apple-converted-space"> </span><a href="mailto:metafoo@gmail.com" target="_blank" style="color: purple; text-decoration: underline; ">metafoo@gmail.com</a><span class="Apple-converted-space"> </span>[mailto:<a href="mailto:metafoo@gmail.com" target="_blank" style="color: purple; text-decoration: underline; ">metafoo@gmail.com</a>]<span class="Apple-converted-space"> </span><b>On Behalf Of<span class="Apple-converted-space"> </span></b>Richard Smith<br><b>Sent:</b><span class="Apple-converted-space"> </span>Tuesday, March 12, 2013 7:01 PM<br><b>To:</b><span class="Apple-converted-space"> </span>Vane, Edwin<br><b>Cc:</b><span class="Apple-converted-space"> </span>Clang Dev List (<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank" style="color: purple; text-decoration: underline; ">cfe-dev@cs.uiuc.edu</a>)<br><b>Subject:</b><span class="Apple-converted-space"> </span>Re: [cfe-dev] Missing info from TypeLoc?</span><o:p></o:p></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "> <o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">On Tue, Mar 12, 2013 at 12:28 PM, Vane, Edwin <<a href="mailto:edwin.vane@intel.com" target="_blank" style="color: purple; text-decoration: underline; ">edwin.vane@intel.com</a>> wrote:<o:p></o:p></div><div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin: 5pt 0in 5pt 4.8pt; "><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">Hi all,<br><br>Given this c++ code:<br><br>const MyType *a;<br><br>The TypeSourceInfo from the VarDecl provides a TypeLoc that claims the type starts at "MyType" not "const". Is this by design or is there a bug here?<o:p></o:p></div></blockquote><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "> <o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">QualifiedTypeLoc does not store location information for the type qualifiers. This is "intentional" but clearly not ideal for tooling clients of type location information. Since the decl-specifiers for such a declaration can be in any order, the source range for such a type isn't necessarily going to be useful, and you may be able to get the information you're looking for by just looking at the start location of the Decl.<o:p></o:p></div></div></div></div></blockquote></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div></div>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</div></blockquote></div><br></body></html>