aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2022-02-22 15:27:47 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2022-02-23 10:54:32 +0000
commitcf902649713ed2fd584e5aca89328c4f99ca0223 (patch)
tree10b0b3e3c68c3005e18810dc5a10d8858427f403
parent7b82b55b73f7c788bf8cb48a30b032a42cf93bcb (diff)
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>
-rw-r--r--src/plugins/clangcodemodel/clangdclient.cpp2
-rw-r--r--src/plugins/clangcodemodel/test/clangdtests.cpp4
-rw-r--r--src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp9
3 files changed, 15 insertions, 0 deletions
diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp
index d0a54042df..50bd7ee24a 100644
--- a/src/plugins/clangcodemodel/clangdclient.cpp
+++ b/src/plugins/clangcodemodel/clangdclient.cpp
@@ -2675,6 +2675,8 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
|| path.rbegin()->kind() == "CXXConstruct")) {
return false;
}
+ if (path.rbegin()->hasConstType())
+ return false;
for (auto it = path.rbegin() + 1; it != path.rend(); ++it) {
if (it->kind() == "Call" || it->kind() == "CXXConstruct"
|| it->kind() == "MemberInitializer") {
diff --git a/src/plugins/clangcodemodel/test/clangdtests.cpp b/src/plugins/clangcodemodel/test/clangdtests.cpp
index 6efddf7c20..98e720ba25 100644
--- a/src/plugins/clangcodemodel/test/clangdtests.cpp
+++ b/src/plugins/clangcodemodel/test/clangdtests.cpp
@@ -1298,6 +1298,10 @@ void ClangdTestHighlighting::test_data()
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 << 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()
diff --git a/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp b/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp
index 40a4ef23b4..6230e7f039 100644
--- a/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp
+++ b/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp
@@ -935,3 +935,12 @@ void outputOperator()
int 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, [] {});
+}