<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 25, 2014 at 3:51 PM, Thompson, John <span dir="ltr"><<a href="mailto:John_Thompson@playstation.sony.com" target="_blank">John_Thompson@playstation.sony.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Hi Richard,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks for the response.<u></u><u></u></p><div class="">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">>But this is a bit of an unusual thing to want to do, and doing the above will be fragile. Maybe there's a better way; what's the larger context?<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
</div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">In Sema::CorrectTypo, I’ve looked up a type name in the GlobalModuleIndex, and found the corresponding type via getTypeName in the form of a ParsedType that
 seems to contain an ExtQualsTypeCommonBase.  I want to create a TypoCorrection, and I think I need to give it a NamedDecl for the type via TypoCorrection::setCorrectionDecl, but I couldn’t figure out how to find it.  I’m I on the right track?  This is regarding
 moving the code for looking for a mission module import into CorrectTypo, per your suggestion.</span></p></div></div></blockquote><div><br></div><div>I don't think you need to call getTypeName here. It sounds like you want to look up a declaration; getTypeName does that and then does some other stuff that you don't want. Without knowing exactly what you're trying to do, I'd think you probably want to invoke name lookup yourself from CorrectTypo.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> <a href="mailto:metafoo@gmail.com" target="_blank">metafoo@gmail.com</a> [mailto:<a href="mailto:metafoo@gmail.com" target="_blank">metafoo@gmail.com</a>]
<b>On Behalf Of </b>Richard Smith</span><br></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<b>Sent:</b> Tuesday, March 25, 2014 3:34 PM<br>
<b>To:</b> Thompson, John<br>
<b>Cc:</b> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [cfe-dev] queston for clang developers: Given a ParsedType in a Sema function, how can I get the corresponding NamedDecl?<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">On Tue, Mar 25, 2014 at 3:05 PM, Thompson, John <<a href="mailto:John_Thompson@playstation.sony.com" target="_blank">John_Thompson@playstation.sony.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I have a ParsedType returned from a getTypeName call in a Sema function.  How can I find the corresponding NamedDecl?<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">To confirm: you're looking for the NamedDecl that declares the type found by name lookup in getTypeName?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">First convert the ParsedType to a QualType by calling GetTypeFromParser.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Then switch over the type class of the Type* in the QualType, and pick the declaration out of it. You'd need to handle at least UnresolvedUsingType, TypedefType, TagType, ElaboratedType, TemplateTypeParmType, TemplateSpecializationType,
 InjectedClassNameType, DependentNameType, and DependentTemplateSpecializationType. Maybe some of the ObjC types too.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">But this is a bit of an unusual thing to want to do, and doing the above will be fragile. Maybe there's a better way; what's the larger context?<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div></div></div>
</div>

</blockquote></div><br></div></div>