From 3173f6fb3ed2e4b85aa60ea448577e36d46b7b52 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen <erik.verbruggen@digia.com> Date: Fri, 12 Apr 2013 13:45:02 +0200 Subject: [PATCH] C++: fix highlighting for template parameters for function calls. Change-Id: Ie0133893d8b8d35ea2aa599cb8f7d5c2cc55271e Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com> --- src/plugins/cpptools/cppchecksymbols.cpp | 4 +++ .../checksymbols/tst_checksymbols.cpp | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/plugins/cpptools/cppchecksymbols.cpp b/src/plugins/cpptools/cppchecksymbols.cpp index 6ae41a37842..2b48ae1e115 100644 --- a/src/plugins/cpptools/cppchecksymbols.cpp +++ b/src/plugins/cpptools/cppchecksymbols.cpp @@ -594,6 +594,8 @@ bool CheckSymbols::visit(CallAST *ast) if (QualifiedNameAST *q = memberName->asQualifiedName()) { checkNestedName(q); memberName = q->unqualified_name; + } else if (TemplateIdAST *tId = memberName->asTemplateId()) { + accept(tId->template_argument_list); } if (!maybeAddFunction(candidates, memberName, argumentCount) @@ -611,6 +613,8 @@ bool CheckSymbols::visit(CallAST *ast) if (QualifiedNameAST *q = exprName->asQualifiedName()) { checkNestedName(q); exprName = q->unqualified_name; + } else if (TemplateIdAST *tId = exprName->asTemplateId()) { + accept(tId->template_argument_list); } const QList<LookupItem> candidates = diff --git a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp index e8b8e98f54e..b5ee70b5239 100644 --- a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp +++ b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp @@ -184,6 +184,7 @@ private slots: void test_checksymbols_QTCREATORBUG8890_danglingPointer(); void test_checksymbols_QTCREATORBUG8974_danglingPointer(); void operatorAsteriskOfNestedClassOfTemplateClass_QTCREATORBUG9006(); + void test_checksymbols_templated_functions(); }; void tst_CheckSymbols::test_checksymbols_TypeUse() @@ -1387,7 +1388,34 @@ void tst_CheckSymbols::operatorAsteriskOfNestedClassOfTemplateClass_QTCREATORBUG ; TestData::check(source, expectedUses); +} + +void tst_CheckSymbols::test_checksymbols_templated_functions() +{ + const QByteArray source = + "struct D {};\n" // line 1 + "struct A {\n" // line 2 + " template<typename T> int B();\n" // line 3 + " void C() {\n" // line 4 + " B<D>();\n" // line 5 + " this->B<D>();\n" // line 6 + " }\n" // line 7 + "};\n" // line 8 + ; + const QList<Use> expectedUses = QList<Use>() + << Use(1, 8, 1, SemanticInfo::TypeUse) + << Use(2, 8, 1, SemanticInfo::TypeUse) + << Use(3, 23, 1, SemanticInfo::TypeUse) + << Use(3, 30, 1, SemanticInfo::FunctionUse) + << Use(4, 10, 1, SemanticInfo::FunctionUse) + << Use(5, 9, 1, SemanticInfo::FunctionUse) + << Use(5, 11, 1, SemanticInfo::TypeUse) + << Use(6, 15, 1, SemanticInfo::FunctionUse) + << Use(6, 17, 1, SemanticInfo::TypeUse) + ; + + TestData::check(source, expectedUses); } QTEST_APPLESS_MAIN(tst_CheckSymbols) -- GitLab