seems like we use the wrong clang api somewhere, or it's unclear Reproducible: Always Steps to Reproduce: struct Foo {}; template<class T> T *acquire(const Foo &name) { return new T; } hover over acquire and look at whats getting shown: Actual Results: T* acquire(const Foo &T); Expected Results: T* acquire(const Foo &name);
the problem is that we don't open another context for the template paramters, and simply put their declarations into the function context, which usually starts with the function arguments... this then confuses DUChainUtils::getArgumentContext which then leads to wrong association in AbstractDeclarationNavigationContext::htmlFunction (and probably elsewhere).
Git commit 0dac419e2fe7428ed9ce6134c1ff674874ccca2a by Milian Wolff. Committed on 08/09/2016 at 17:01. Pushed by mwolff into branch '5.0'. Add unit test with expected failure for template functions with args. Since we put template parameters into the function context, which usually starts with the function arguments, things get confused elsewhere. We really need to create a separate context for the template parameters... M +34 -0 languages/clang/tests/test_duchain.cpp M +1 -0 languages/clang/tests/test_duchain.h http://commits.kde.org/kdevelop/0dac419e2fe7428ed9ce6134c1ff674874ccca2a
This gets much weirder with multiple parameters. The last parameter disappears entirely, and the types are offset from the parameter names. Compare the tooltip to the actual definition here: http://www.flherne.uk/files/Screenshot_20160912_102316.png When there are multiple versions with different parameter lists, it gets even more confusing because the parser connects uses to the wrong definition. The three variants of DeclarationBuilder::visitVariableDeclaration() in kdev-python/duchain/declarationbuilder.cpp display this quite well/badly.
I think https://reviews.llvm.org/D13599 can help to get this fixed. In the meantime, ideas on how to improve that situation are welcome :)