<div dir="ltr"><div><div>Hi Michael,<br><br></div>I haven't used libclang much (my use case requires LibTooling) but I think you want to get the underlying type from the typedef and then use getTypeSpelling on that result. Basically you want to check if CXType.kind is CXType_Typedef and if so, get the underlying type (which in this case should be "Bar") and then call clang_getTypeSpelling on that result. <br><br></div><div>I don't know anything about CXCursors or CXTypes so I'll leave it to you to figure out how to get the underlying type, but hopefully this helps.<br><br></div><div>-Adam<br></div><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 27, 2016 at 8:55 AM, Michael via cfe-users <span dir="ltr"><<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@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">Nobody? Wrong list? Any insight in this would be greatly appreciated.<br>
<br>
Thanks<span class="HOEnZb"><font color="#888888"><br>
<br>
Michael</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 08/30/2016 07:00 PM, Michael via cfe-users wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi<br>
<br>
Hope I picked the right place for this kind of problem, if not please let me know.<br>
<br>
I'm using libclang to parse header files and generate code from them. I found that clang_getTypeSpelling() usually includes the namespace(s) a type was declared in. However with the exception being typedefs (and same for "using A = B"). Not sure if this is a bug or intended behavior, but it seems at least inconsistent. I also couldn't really find a good workaround for this. I'd have to manually figure out all typedefs (not just pure typedefs, they could also be template parameters or whatever) and then their originating namespaces. This sounds a bit cumbersome and not really straight forward.<br>
<br>
Minimal example:<br>
<br>
namespace foo {<br>
class Bar {<br>
};<br>
typedef Bar BarDef;<br>
}<br>
<br>
clang_getTypeSpelling on "Bar" (kind "Record") gives: "foo::Bar"<br>
clang_getTypeSpelling on "BarDef" (kind "Typedef") gives: "BarDef" (<== missing "foo::")<br>
<br>
Any idea how to solve this problem? Am I missing something?<br>
<br>
Thanks<br>
<br>
Michael<br>
______________________________<wbr>_________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-users</a><br>
</blockquote>
<br>
______________________________<wbr>_________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-users</a><br>
</div></div></blockquote></div><br></div>