Closed rhdunn closed 6 years ago
So I found out why this happens, at least. So I don't forget, basically the use of a template instantiates a new class, to which the new type refers. The information about this being a templated class is lost, instead you'll obtain the concrete class. At this point it's not possible to easily get back to the templated definition as far as I know. What is possible though, is to get the cursor at the location of the template instantiation, which coincides with the original template declaration, and obtain a cursor to the template.
From there we still need to figure out with which arguments the template was actually instantiated, which might not be trivial to do robustly.
Actually, we can get the templated cursor back, there was just some binding missing.
Is this related to the Unhandled cursor: CursorKind.TEMPLATE_REF
messages I am seeing when building the documentation?
To do this robustly, you need to:
Thus, for:
std::list<std::string, std::allocator<std::string>>
you have:
1: T = std::string , Allocator = std::allocator<std::string>
3: T = std::string , Allocator = std::allocator<T>
4:T = std::string
Unless libclang provides a way of getting this information in the way it has structured the types.
It seems this would be pretty hard to get right currently. It looks like there might be API coming in the next version of libclang (https://github.com/llvm-mirror/clang/blob/master/include/clang-c/Index.h#L3110), but for now it's not available.
This has been fixed in latest master
, but from the looks of it this will only be possible from clang 4.0 or later (3.9 does not expose this information). I'm considering only supporting 4.0 and upwards.
Given:
The XML output for the return type is:
This is including the allocator argument which is the default version from the template declaration. Thus, the allocator should not be present in the output, which should be:
With issue #50 fixed, this should be: