ClangCodeModel: Fix an instance of mis-highlighting with clangd

In the expression x.f(), x was wrongly categorized as an output
parameter if f was a static function.

Change-Id: I9167f98916963cdaa4b5ac6ead2c86fab43ad02e
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2021-09-16 13:37:14 +02:00
parent b771bdf4c1
commit 56f9d17d35
3 changed files with 15 additions and 0 deletions

View File

@@ -2444,6 +2444,10 @@ static void semanticHighlighter(QFutureInterface<TextEditor::HighlightingResult>
}
if (it->kind().endsWith("Cast") && it->hasConstType())
return false;
if (it->kind() == "Member" && it->arcanaContains("(")
&& !it->arcanaContains("bound member function type")) {
return false;
}
}
return false;
};

View File

@@ -1231,6 +1231,10 @@ void ClangdTestHighlighting::test_data()
<< QList<int>{C_PREPROCESSOR, C_DECLARATION} << 0;
QTest::newRow("#ifdef'ed out code") << 800 << 1 << 800 << 17
<< QList<int>{C_DISABLED_CODE} << 0;
QTest::newRow("static function call (object)") << 819 << 5 << 819 << 6
<< QList<int>{C_LOCAL} << 0;
QTest::newRow("static function call (argument)") << 819 << 18 << 819 << 19
<< QList<int>{C_LOCAL, C_OUTPUT_ARGUMENT} << 0;
}
void ClangdTestHighlighting::test()

View File

@@ -811,3 +811,10 @@ std::vector<int
>
>
vp3;
void staticMemberFuncTest() {
struct S { static void staticFunc(int &); };
S s;
int i;
s.staticFunc(i);
}