Giter VIP home page Giter VIP logo

Comments (5)

jessevdk avatar jessevdk commented on July 23, 2024

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.

from cldoc.

jessevdk avatar jessevdk commented on July 23, 2024

Actually, we can get the templated cursor back, there was just some binding missing.

from cldoc.

rhdunn avatar rhdunn commented on July 23, 2024

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:

  1. know what each template parameter expands to;
  2. know which parameters are defined in terms of other parameters (e.g. for std::list, Allocator is defined in terms of T);
  3. reverse the type expansion for parameters identified in (2);
  4. remove the template parameters whose signature matches the default parameters.

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.

from cldoc.

jessevdk avatar jessevdk commented on July 23, 2024

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.

from cldoc.

jessevdk avatar jessevdk commented on July 23, 2024

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.

from cldoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.