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

Prefer canonical references for using-imported decalrations #320

Open
varungandhi-src opened this issue May 17, 2023 · 1 comment
Open

Comments

@varungandhi-src
Copy link
Contributor

varungandhi-src commented May 17, 2023

Say I have code like the following:

namespace x {
  struct S {};
}
namespace y {
  using x::S; // equivalent to `using S = x::S`
  void f() {
    S{}; y::S{};
  }
}

The question is what should Go to Definition behave like when:

  1. Trying GTD from S{}
  2. Trying GTD from y::S{}

In both cases, GTD in VS Code/clangd shows both the struct and using lines. In CLion, both go directly to the struct line.

As it stands, scip-clang will emit a reference to y::S and take one to the using line directly. While this is technically correct, attempting Go to Definition to the using line doesn't do anything (even though there is a reference to x::S). Example in LLVM:

image

For now, I think we should just emit a reference to the canonical declaration directly. If we add support for some kind of alias role, then we can also emit a definition for the alias declaration.

@varungandhi-src varungandhi-src added the enhancement New feature or request label May 17, 2023
@varungandhi-src
Copy link
Contributor Author

We should also do this for declarations inside templates, which currently don't have any occurrence (definition or reference), see the test case added in #321

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

No branches or pull requests

1 participant