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

Heuristic resolution does not find member of type referenced via alias template #1663

Closed
HighCommander4 opened this issue Jun 5, 2023 · 4 comments
Assignees

Comments

@HighCommander4
Copy link

In the following code:

template <typename T>
struct Waldo {
  void find();
};

template <typename T>
using Wally = Waldo<T>;

template <typename T>
void foo(Wally<T> w) {
  w.find();
}

go-to-definition on the use of find() does not produce Waldo::find().

@HighCommander4 HighCommander4 changed the title HeuristicResolver does not find member of type referenced via alias template Heuristic resolution does not find member of type referenced via alias template Jun 5, 2023
@HighCommander4
Copy link
Author

This is similar to #1657, except that the fix is in HeuristicResolver rather than in CXXRecordDecl::lookupDependentName().

(With #1662 in place, the implementation of lookupDependentName() could then reuse the logic to handle alias templates that I'm going to add to HeuristicResolver in this issue.)

@HighCommander4 HighCommander4 self-assigned this Jun 9, 2023
@HighCommander4
Copy link
Author

HighCommander4 commented Jun 9, 2023

I wrote a fix for this (https://reviews.llvm.org/D152500), but I'm not satisfied with it.

While my fix handles the above testcase specifically, it does not handle this modified testcase:

template <typename T>
struct Waldo {
  void find();
};

template <typename T>
struct MetaWaldo {
  using Type = Waldo<T>;
};

template <typename T>
void foo(typename MetaWaldo<T>::Type w) {
  w.find();
}

even though clangd can resolve the use of MetaWaldo<T>::Type to its declaration.

I would like to find a solution that doesn't require manual handling for every kind of type sugar.

@HighCommander4
Copy link
Author

I have updated my patch to take a more general approach. The example in the previous comment is still not handled; I mischaracterized it as being another example of type sugar when in fact it's not -- there is a heuristic resolution step involved, because class templates can be specialized while alias templates can't. I'll file a follow-up issue for this.

@HighCommander4
Copy link
Author

I'll file a follow-up issue for this.

The follow-up is #1671

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

1 participant