On Fri, Feb 15, 2013 at 1:56 PM, James Abbatiello <span dir="ltr"><<a href="mailto:abbeyj@gmail.com" target="_blank">abbeyj@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div><div><div>I managed to get something close by hacking Sema::GetNameForDeclarator like so:<br>DeclarationNameInfo Sema::GetNameForDeclarator(Declarator &D) {<br>  DeclarationNameInfo ret = GetNameFromUnqualifiedId(D.getName());<br>

  if (D.getName().getKind() == UnqualifiedId::IK_DestructorName &&<br>      ret.getName() &&<br>      !ret.getNamedTypeInfo())<br>  {<br>    ret.setNamedTypeInfo(GetTypeForDeclarator(D, NULL));<br>  }<br>
  return ret;<br>
}<br><br><br></div>I
 couldn't figure out how to do something similar from 
Sema::getDestructorName since there's no Declarator available there.  
And if I try to use getTrivialTypeSourceInfo from getDestructorName then
 I run into two problems: <br><br>1) I only have the QualType for the class, not for the destructor itself<br></div>2) Even if I make a QualType with Context.getFunctionType, getTrivialTypeSourceInfo only takes one SourceLocation<br>
</div></div></div></div></blockquote><div><br></div><div>getDestructorName returns a ParsedType for the T in ~T, so you don't need a Declarator, and shouldn't be building a function type.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div></div>Even
 with the above patch I still have a problem in that the source range 
covers not only the tilde and the name but also the opening and closing 
parentheses.<br><br></div>If anybody has any advice for me, I'd love to hear it.  I'm rather stuck at the moment.<span class="HOEnZb"><font color="#888888"><br><br>-- <br></font></span></div><span class="HOEnZb"><font color="#888888">James Abbatiello<br>
<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Feb 14, 2013 at 3:23 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>On Thu, Feb 14, 2013 at 11:20 AM, James Abbatiello <span dir="ltr"><<a href="mailto:abbeyj@gmail.com" target="_blank">abbeyj@gmail.com</a>></span> wrote:<br></div><div class="gmail_quote"><div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div>Hi Richard,<br><br></div>Thanks for your response.  I'm not familiar with clang internals so I'm still confused.  How could a TypeSourceInfo be built in this function?  And what would be done with it one you had it?  The function looks like it is supposed to return the type of the class, at least if I'm understanding correctly.  Are you proposing that it instead return the TypeSourceInfo and other code be refactored?  Or that there's some place to store the TypeSourceInfo and then retrieve it later in Sema::GetNameFromUnqualifiedId?</div>


</div></blockquote><div><br></div></div><div>ParsedType can hold the TypeSourceInfo, via the LocInfoType you discovered; use Sema::CreateParsedType to create the ParsedType. You can build an appropriate TypeSourceInfo using ASTContext::getTrivialTypeSourceInfo(QualType, SourceLocation).</div>

<div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span><font color="#888888"><br>-- <br></font></span></div><span><font color="#888888">James Abbatiello<br>


<br></font></span></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 13, 2013 at 6:00 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Looks like the root cause here is that Sema::getDestructorName isn't building a TypeSourceInfo for the destructor name.<br>



<br><div class="gmail_quote"><div><div>On Wed, Feb 13, 2013 at 2:23 PM, James Abbatiello <span dir="ltr"><<a href="mailto:abbeyj@gmail.com" target="_blank">abbeyj@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div>Hello,<br><br>I've been looking into <a href="http://llvm.org/bugs/show_bug.cgi?id=15125" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=15125</a> and I think I have an idea of where the problem is coming from but not how to fix it.  Advice or input of any kind would be welcome.<br>





<br>At <a href="http://clang.llvm.org/doxygen/DeclarationName_8cpp_source.html#l00578" target="_blank">http://clang.llvm.org/doxygen/DeclarationName_8cpp_source.html#l00578</a>, the  TInfo variable is always NULL in my experiments.  So the code returns NameLoc (the start location) instead of the end.<br>





<br>This NULL value comes from <a href="http://clang.llvm.org/doxygen/d9/d4f/SemaDecl_8cpp_source.html#l03002" target="_blank">http://clang.llvm.org/doxygen/d9/d4f/SemaDecl_8cpp_source.html#l03002</a>.  This code calls GetTypeFromParser with the type of the class (a RecordType).  GetTypeFromPointer will then try to dyn_cast this to LocInfoType which gets NULL.  That NULL eventually ends up in TInfo above.<br>





<br>At this point we have both the needed SourceLocations in Name.StartLocation and Name.EndLocation but we need a LocInfoType instead.  Can I retrieve or construct one that's appropriate here?  Or should the anonymous union in DeclarationNameLoc be extended to be able to hold a TInfo* and an end location when handling one of CXXConstructorName, CXXDestructorName and CXXConversionFunctionName?<span><font color="#888888"><br>





<br>-- <br></font></span></div><span><font color="#888888">James Abbatiello<br><br></font></span></div>
<br></div></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br>
</blockquote></div><br></div>
</div></div></blockquote></div></div><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br>