[cfe-dev] CXCursor_CXXBaseSpecifier for template instantiated base class

Michael via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 17 06:00:15 PDT 2017


On 03/17/2017 10:55 AM, Jusufadis Bakamovic wrote:
>
> I am not sure if I understood you correctly but:
>
>
>     You also want to know that the specialised parameter of
>     “BaseTemplate" is “Base”
>
>
> Sure, you can get this information once you _instantiate_ a class from
> your class template. I.e.
>     class Base {};
>     class Derived : public RecursiveBase<Base> {};
>
> Traversing the AST and getting to the 'CXCursor_TypeRef's of 'Derived'
> will get you this information.
>
>
>     And you also want to know that arg1 and arg2 of the specialised
>     “RecursiveBase” are of type “Base”
>
>
> If you have the information that 'Derived' is built with 'Base', which
> you do have, then you should be able to match this information against
> 'foo()'/'bar()' and corresponding arguments.

Plus you have to take the detour via the ClassTemplates to find out 
which and where template parameters are used and passed on to possible 
base templates... So yes, this is basically what I said. It's possible 
to match things manually. But it gets cumbersome in the general case, if 
you have deeper hierarchies, more parameters.
(While the needed information is actually already available in clang as 
ClassTemplateSpecializationDecl, just not exposed by libclang.)

> Not every use-case is covered and exposed via libclang API. There are
> situations where you will have to handle your specific use-cases
> manually with your code (as shown above). If shown that these use-cases
> might be relevant for general purpose then you might go ahead and issue
> a patch to libclang API.

Right, I might actually do that. I just wanted to figure out first 
whether I'm maybe just missing something.


Thanks

Michael



More information about the cfe-dev mailing list