[cfe-dev] accessing template arguments from libclang

Geoffrey Irving irving at naml.us
Fri Nov 1 12:37:27 PDT 2013


Okay, I've diagnosed the problem:

   https://github.com/llvm-mirror/clang/blob/c6911a2b1fc176e4d6053ed86506c17c3d8b0057/tools/libclang/CIndex.cpp#L670

Patch coming up.

Geoffrey

On Thu, Oct 31, 2013 at 10:23 PM, Anthony Scopatz <scopatz at gmail.com> wrote:
> Hello All,
>
> Any guidance that you can provide would be most beneficial since we really
> need this feature for the xdress project.  Thanks!
>
> Be Well
> Anthony
>
>
>> Another ping for this message: let me know if this is the wrong forum
>> for questions about libclang.
>> Geoffrey
>> On Thu, Aug 15, 2013 at 10:36 AM, Geoffrey Irving <irving at naml.us>
>> wrote:
>> > In case the previous email was too long, here's a quick summary:
>> >
>> > I am trying to parse the code
>> >
>> >
>> > class Toaster : Base<int,7> { ... };
>> >
>> > I can get to the base specifier corresponding to Base<int,7> and from
>> > there
>> > to a RECORD type, but there appears to be no way to access the template
>> > arguments of a template reference from either the Python or C bindings
>> > to
>> > clang. If I'm correct that this isn't exposed yet, what's the right way
>> > to
>> > do it?
>> >
>> > Thanks,
>> > Geoffrey
>> >
>> >
>> > On Tue, Aug 13, 2013 at 12:26 PM, Geoffrey Irving <irving at naml.us>
>> > wrote:
>> >>
>> >> I am trying to parse the following code with the Python interface to
>> >> libclang (full listing attached):
>> >>
>> >> class Toaster : Base<int,7> { ... };
>> >>
>> >> Unfortunately, traversing cursors via getChildren gives me the
>> >> following
>> >> tree (see clang_dump() in autodescribe.py for the code that generated
>> >> this
>> >> tree):
>> >>
>> >> CLASS_DECL Toaster
>> >> CXX_BASE_SPECIFIER None : Base<int,7>
>> >> TEMPLATE_REF None : Base
>> >> INTEGER_LITERAL None : 7
>> >> CXX_ACCESS_SPEC_DECL PUBLIC : public:
>> >> ...
>> >>
>> >> The base specifier only seems to mention "Base" and "7", not "int".
>> >> Should I be able to fully inspect Base<int,7> using cursors?
>> >>
>> >> I also tried traversing the Type object corresponding to Base<int,7>,
>> >> but
>> >> I don't see any methods for accessing template parameters either in
>> >> libclang's Python bindings or in the original C. If I'm correct that
>> >> the
>> >> functionality is missing from the C layer, what's the easiest way to
>> >> add it?
>> >> The C++ structure of template references seems quite complicated (I
>> >> imagine
>> >> by necessity :)).
>> >>
>> >> Background: I'm working on a clang-based front end for the xdress
>> >> Python
>> >> binding generator project. I've already made a couple minor
>> >> improvements to
>> >> the libclang Python bindings (exposing formatDiagnostic and the details
>> >> of
>> >> access specifiers), and am happy to contribute these back once I'm
>> >> done.
>> >>
>> >> Thanks for any suggestions!
>> >> Geoffrey
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>



More information about the cfe-dev mailing list