[cfe-dev] problem with template class inheritance and cursor api

David Röthlisberger david at rothlis.net
Fri Jan 18 09:40:10 PST 2013


On 18 Jan 2013, at 08:38, Anders Bakken wrote:
> Hi
> 
> I'm writing a clang-based c++/c indexer
> (https://github.com/Andersbakken/rtags/) and I am having a problem
> with the following construct:
> 
> // -----------------
> template <typename T>
> class A
> {
> public:
>    int size() const { return 1; }
> };
> 
> template <typename T>
> class B : public A<T>
> {
> public:
>    bool isEmpty() const { return A<T>::size(); }
> };
> 
> // -----------------
> 
> There seems to be way to get from this cursor(s) for the call to
> A<T>::size() to the actual function (A<T>::size).


Could you post a code snippet showing the API you are using that *does*
work to find a member function's definition from the call site when that
call site *isn't* in a subclass, or when the superclass isn't templated?
And then a code snippet showing the (hypothetical) API you would
*expect* to be able to use for your test case.

FYI for exploring the libclang API I found the python bindings, plus
ipython (an interactive python interpreter with tab-completion)
extremely helpful. See for example
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-August/023449.html
-- judging from your rtags tool you either know this already, or don't
need it, but I thought I'd mention it just in case. :-)

Thanks,
Dave.



More information about the cfe-dev mailing list