Bug 368460 - function signature picks up template parameter names
Summary: function signature picks up template parameter names
Status: CONFIRMED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-08 16:27 UTC by Milian Wolff
Modified: 2016-09-13 20:43 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milian Wolff 2016-09-08 16:27:46 UTC
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);
Comment 1 Milian Wolff 2016-09-08 16:51:01 UTC
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).
Comment 2 Milian Wolff 2016-09-08 17:01:26 UTC
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
Comment 3 Francis Herne 2016-09-12 09:31:08 UTC
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.
Comment 4 Milian Wolff 2016-09-13 20:43:45 UTC
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 :)