Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for member specialization roadmap/workarounds #127

Open
deadlocklogic opened this issue Nov 29, 2021 · 6 comments
Open

Support for member specialization roadmap/workarounds #127

deadlocklogic opened this issue Nov 29, 2021 · 6 comments

Comments

@deadlocklogic
Copy link

This is already mentioned:
Support for member specialization: members of a template can be specialized separately, this is not supported.
But is it a limitation from clang or missing for the time being in cppast?

Consider:

template <class T> struct Temp1{
  template <class T> struct Temp2{
  };
};

using DeepNested = Temp1<int>::Temp2<int>;

Even thought cpp_type_alias::underlying_type()::primary_template()::no_overloaded() is 1.
Any ideas if this would be implemented in the future?
Are there any workarounds?

@deadlocklogic
Copy link
Author

deadlocklogic commented Nov 29, 2021

Basically consider these 2 files:
File1:

namespace ns {
template <class T> struct Temp1 {
  template <class T> struct Temp2 {};
};
} // namespace ns

File2:

namespace ns {
using DeepNested1 = Temp1<int>::Temp2<int>;
using DeepNested2 = ns::Temp1<int>::Temp2<int>;
} // namespace ns

I can't figure out how to resolve DeepNested1, at least I want the referring template entity of Temp2(Temp1 is ok too, basically I want to know in which scope the referring type resides) so I can workout a hacky way around parsing type arguments.

All I need is to know which template entity Temp2 refers to.

@foonathan Any thoughts?

@foonathan
Copy link
Collaborator

I don't think libclang provides APIs to handle it. This might be possible to fix with #120.

@deadlocklogic
Copy link
Author

@foonathan Why not using dump-json just to get around this libclang limitation?. Because the feature/json branch is far from complete. So instead of writing huge chunk of it, just patch the current implementation?
Thanks again, this library is really useful but still needs the last part of the puzzle.

@foonathan
Copy link
Collaborator

It's not easy to mix the two modes, I might as well just add another "backend." Yes, progress is slow, PRs are welcome. ;)

@deadlocklogic
Copy link
Author

Yes of course PR are awesome!
I would really like to dig into a libtooling backend but I have trouble setting it up (what I am doing is using their setup for building with ninja + hacking around CMake to use VS as IDE).
dump-json can be feature complete and probably I have to study it myself more.
But the big question is: can the dumped data be easily navigated? Because it is funny if a json can provide infos better than libclang itself. I guess I should take a look first maybe. 😭
I will try to study the feature/json branch and see how things are working there.

@foonathan
Copy link
Collaborator

I would really like to dig into a libtooling backend but I have trouble setting it up (what I am doing is using their setup for building with ninja + hacking around CMake to use VS as IDE).

Yes, this is one of the reason I'm not using libtooling: it's not really designed for projects that live outside the clang source tree. The API is also unstable.

But the big question is: can the dumped data be easily navigated? Because it is funny if a json can provide infos better than libclang itself. I guess I should take a look first maybe. sob

I'm using simdjson, which parses it on demand during navigation. It's a bit finicky at times, but otherwise works well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants