This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Navigation from definition of template specialization to primary template
ClosedPublic

Authored by nridge on Dec 5 2019, 1:37 PM.

Event Timeline

nridge created this revision.Dec 5 2019, 1:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2019, 1:37 PM
sammccall accepted this revision.Dec 6 2019, 3:48 AM

Nice!

clang-tools-extra/clangd/XRefs.cpp
194

Not thrilled about reusing this after previous patches disentangled it - it works well for macros but if (for example) you have a templated operator<< I think the feature you're adding probably won't work.

That said, I don't see a simple alternative, and it's unlikely to be a big deal, so I think this is OK.

240

Be aware that this is going to break "go to definition" toggling between def and decl. I think that's fine.

240

(I think you probably want the macro-arg-expanded location here)

This revision is now accepted and ready to land.Dec 6 2019, 3:48 AM
nridge updated this revision to Diff 232725.Dec 7 2019, 9:38 PM
nridge marked 2 inline comments as done.
nridge retitled this revision from [clangd] Navigation from definition of template specialization to primary template Fixes https://github.com/clangd/clangd/issues/212. to [clangd] Navigation from definition of template specialization to primary template.
nridge edited the summary of this revision. (Show Details)

Address comment

clang-tools-extra/clangd/XRefs.cpp
240

For what will this break toggling? Aas far as I'm aware, partial and explicit specializations of templates do not have separate declarations.

This revision was automatically updated to reflect the committed changes.
nridge marked an inline comment as done.Dec 7 2019, 9:45 PM
nridge added inline comments.
clang-tools-extra/clangd/XRefs.cpp
240

I stand corrected: I checked, and it seems like specializations can indeed have forward declarations.

I expect they are relatively rare, though, and it's probably fine to break toggling for them, like you said.