During template argument deduction, KDevelop doesn't drop references. Sample code: template<typename T> void foo(T x); int main() { int num=42; int& ref=num; foo(num); foo(ref); } The first call to 'foo' is marked as a use of 'void foo<int>(int)', and the second as a use of 'void foo<int&>(int&)'. However, both should be foo<int>. According to the C++ specification (N3242=11-0012, section 14.8.2.1), "If P is a reference type, the type referred to by P is used for type deduction."
This is still a problem in KDevelop 4.4.1
This seems vaguely related to 1d0079f4.
Thank you for the bug report. As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists. If this bug is no longer persisting or relevant please change the status to resolved.
This bug applied to the old C++ parser, so surely the new clang-based parser fixed it, right? Well, I tried it in a current KDevelop with the new clang-based parser and the code above shows both calls to foo as void foo( T x ). Is it dropping references when doing type deduction? Probably (so I'll close the bug as fixed), but I can't really tell, it's not showing any template parameters in the tooltip anymore... Maybe showing template parameters in the tooltip is a feature that should be brought back.
(In reply to Nicolás Alvarez from comment #4) > Well, I tried it in a current KDevelop with the new clang-based parser and > the code above shows both calls to foo as void foo( T x ). Is it dropping > references when doing type deduction? Probably (so I'll close the bug as > fixed), but I can't really tell, it's not showing any template parameters in > the tooltip anymore... Clang at least does the type deduction right. You can convince yourself on the command line by running it with "-fsyntax-only -Xclang -ast-dump". > Maybe showing template parameters in the tooltip is a feature that should be > brought back. Tough. The c-index that we use doesn't contain that information apparently. At least "c-index-test -index-file" on the example code spits out [startedTranslationUnit] [enteredMainFile]: <stdin> [indexDeclaration]: kind: function-template | name: foo | USR: c:@FT@>1#Tfoo#t0.0#v# | lang: C++ | cursor: FunctionDecl=foo:1:27 | loc: 1:27 | semantic-container: [TU] | lexical-container: [TU] | isRedecl: 0 | isDef: 0 | isContainer: 0 | isImplicit: 0 [indexDeclaration]: kind: function | name: main | USR: c:@F@main# | lang: C | cursor: FunctionDecl=main:3:5 (Definition) | loc: 3:5 | semantic-container: [TU] | lexical-container: [TU] | isRedecl: 0 | isDef: 1 | isContainer: 1 | isImplicit: 0 [indexEntityReference]: kind: function-template | name: foo | USR: c:@FT@>1#Tfoo#t0.0#v# | lang: C++ | cursor: DeclRefExpr=foo:1:27 | loc: 6:4 | <parent>:: kind: function | name: main | USR: c:@F@main# | lang: C | container: [main:3:5] | refkind: direct | role: ref call [indexEntityReference]: kind: function-template | name: foo | USR: c:@FT@>1#Tfoo#t0.0#v# | lang: C++ | cursor: DeclRefExpr=foo:1:27 | loc: 7:4 | <parent>:: kind: function | name: main | USR: c:@F@main# | lang: C | container: [main:3:5] | refkind: direct | role: ref call As you can see the calls at 6:4 and 7:4 just contain a reference to the function template foo:1:27 (the numbers are line:column). One would think that the magic string tells us something alas another line foo(1.0); produces the same magic string: [indexEntityReference]: kind: function-template | name: foo | USR: c:@FT@>1#Tfoo#t0.0#v# | lang: C++ | cursor: DeclRefExpr=foo:1:27 | loc: 8:4 | <parent>:: kind: function | name: main | USR: c:@F@main# | lang: C | container: [main:3:5] | refkind: direct | role: ref call