ClangCodeModel: Do not highlight argument of operator*

... as output parameter with clangd.

Task-number: QTCREATORBUG-27111
Change-Id: I5def562dcb9b8b0dac036fd46ed7e996c0297c95
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-02-28 16:02:59 +01:00
parent c7d2b8d5cb
commit 41038ba8cf
3 changed files with 13 additions and 1 deletions

View File

@@ -2711,7 +2711,8 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
if (detail.startsWith("operator")) {
return !detail.contains('=')
&& !detail.contains("++") && !detail.contains("--")
&& !detail.contains("<<") && !detail.contains(">>");
&& !detail.contains("<<") && !detail.contains(">>")
&& !detail.contains("*");
}
firstChildTree << n.children().value_or(QList<AstNode>());
}

View File

@@ -1308,6 +1308,8 @@ void ClangdTestHighlighting::test_data()
<< QList<int>{C_PREPROCESSOR} << 0;
QTest::newRow("built-in define 3") << 952 << 21 << 952 << 40
<< QList<int>{C_PREPROCESSOR} << 0;
QTest::newRow("deref operator (object)") << 960 << 10 << 960 << 11 << QList<int>{C_LOCAL} << 0;
QTest::newRow("deref operator (member)") << 960 << 12 << 960 << 13 << QList<int>{C_FIELD} << 0;
}
void ClangdTestHighlighting::test()

View File

@@ -951,3 +951,12 @@ void builtinDefines()
const auto f2 = __FUNCTION__;
const auto f3 = __PRETTY_FUNCTION__;
}
void derefOperator()
{
struct S { bool operator*(); };
struct S2 { S s; };
S2 s;
if (*s.s)
return;
}