diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index b76bc58b6cc..a8a1fbe5a90 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -2605,8 +2605,6 @@ static void semanticHighlighter(QFutureInterface &future, const QList path = getAstPath(ast, range); if (path.size() < 2) return false; - if (path.last().hasConstType()) - return false; for (auto it = path.rbegin() + 1; it != path.rend(); ++it) { if (it->kind() == "Call" || it->kind() == "CXXConstruct" || it->kind() == "MemberInitializer") { @@ -2636,7 +2634,7 @@ static void semanticHighlighter(QFutureInterface &future, if (it->kind() == "Lambda") return false; - if (it->kind().endsWith("Cast") && it->hasConstType()) + if (it->hasConstType()) return false; if (it->kind() == "Member" && it->arcanaContains("(") && !it->arcanaContains("bound member function type")) { diff --git a/src/plugins/clangcodemodel/test/clangdtests.cpp b/src/plugins/clangcodemodel/test/clangdtests.cpp index 5d9f6e03589..5a23440eb1c 100644 --- a/src/plugins/clangcodemodel/test/clangdtests.cpp +++ b/src/plugins/clangcodemodel/test/clangdtests.cpp @@ -1277,6 +1277,8 @@ void ClangdTestHighlighting::test_data() << QList{C_STRING} << 0; QTest::newRow("user-defined operator call") << 860 << 7 << 860 << 8 << QList{C_LOCAL} << 0; + QTest::newRow("const member as function argument") << 868 << 32 << 868 << 43 + << QList{C_FIELD} << 0; } void ClangdTestHighlighting::test() diff --git a/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp b/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp index 2290abf3a73..46112c2f136 100644 --- a/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp +++ b/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp @@ -859,3 +859,13 @@ void useOperator() struct S { S& operator++(); } s; ++s; } + +static void takesFoo(const Foo &); +void constMemberAsFunctionArg() +{ + struct S { + S(const Foo& f) : constMember(f) {} + void func() { takesFoo(constMember); } + const Foo &constMember; + }; +}