ClangCodeModel: Fix more false output arguments with clangd

For some reason, we never checked the actual matching AST node for
const-ness.

Change-Id: Icb58ba169d82e1ec02c9ff8d17f0170f0a78f99d
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-22 15:27:47 +01:00
parent 7b82b55b73
commit cf90264971
3 changed files with 15 additions and 0 deletions

View File

@@ -2675,6 +2675,8 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
|| path.rbegin()->kind() == "CXXConstruct")) { || path.rbegin()->kind() == "CXXConstruct")) {
return false; return false;
} }
if (path.rbegin()->hasConstType())
return false;
for (auto it = path.rbegin() + 1; it != path.rend(); ++it) { for (auto it = path.rbegin() + 1; it != path.rend(); ++it) {
if (it->kind() == "Call" || it->kind() == "CXXConstruct" if (it->kind() == "Call" || it->kind() == "CXXConstruct"
|| it->kind() == "MemberInitializer") { || it->kind() == "MemberInitializer") {

View File

@@ -1298,6 +1298,10 @@ void ClangdTestHighlighting::test_data()
QTest::newRow("operator<<") << 934 << 10 << 934 << 14 << QList<int>{C_GLOBAL} << 0; QTest::newRow("operator<<") << 934 << 10 << 934 << 14 << QList<int>{C_GLOBAL} << 0;
QTest::newRow("operator>>") << 936 << 10 << 936 << 13 << QList<int>{C_GLOBAL} << 0; QTest::newRow("operator>>") << 936 << 10 << 936 << 13 << QList<int>{C_GLOBAL} << 0;
QTest::newRow("operator>>") << 936 << 17 << 936 << 18 << QList<int>{C_LOCAL} << 0; QTest::newRow("operator>>") << 936 << 17 << 936 << 18 << QList<int>{C_LOCAL} << 0;
QTest::newRow("input arg from passed object") << 945 << 17 << 945 << 18
<< QList<int>{C_FIELD} << 0;
QTest::newRow("output arg") << 945 << 20 << 945 << 23
<< QList<int>{C_LOCAL, C_OUTPUT_ARGUMENT} << 0;
} }
void ClangdTestHighlighting::test() void ClangdTestHighlighting::test()

View File

@@ -935,3 +935,12 @@ void outputOperator()
int i; int i;
std::cin >> i; std::cin >> i;
} }
template <typename To, typename From, typename Op>
void transform(const From &from, To &&to, Op op) {}
struct WithVector { std::vector<int> v; };
void inputsAndOutputsFromObject(const WithVector &s)
{
std::vector<int> out;
transform(s.v, out, [] {});
}