aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-10-23 16:37:59 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-10-27 11:07:44 +0000
commit2b32b2e4400c58f464fa44375adc819b4d5a0fd7 (patch)
tree018043b476b18ade248c2ed54e9e52082d4f7de7 /tests
parent9c0544c3863da962d07209d823c387066596da1c (diff)
clangbackend: Provide highlighting for structured bindings
These are reported by libclang as "unexposed declarations". Fixes: QTCREATORBUG-24769 Change-Id: I7a74b707f4203becabaa74b90758a7b396ee23bd Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/unittest/data/highlightingmarks.cpp5
-rw-r--r--tests/unit/unittest/tokenprocessor-test.cpp8
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/unit/unittest/data/highlightingmarks.cpp b/tests/unit/unittest/data/highlightingmarks.cpp
index 33dfbe91de..346071dea1 100644
--- a/tests/unit/unittest/data/highlightingmarks.cpp
+++ b/tests/unit/unittest/data/highlightingmarks.cpp
@@ -731,3 +731,8 @@ class Property {
)
};
+
+void structuredBindingTest() {
+ const int a[] = {1, 2};
+ const auto [x, y] = a;
+}
diff --git a/tests/unit/unittest/tokenprocessor-test.cpp b/tests/unit/unittest/tokenprocessor-test.cpp
index f74fb0dbed..62a84af59d 100644
--- a/tests/unit/unittest/tokenprocessor-test.cpp
+++ b/tests/unit/unittest/tokenprocessor-test.cpp
@@ -1759,6 +1759,14 @@ TEST_F(TokenProcessor, TemplateAlias)
ASSERT_THAT(infos[0], HasTwoTypes(HighlightingType::Type, HighlightingType::TypeAlias));
}
+TEST_F(TokenProcessor, StructuredBinding)
+{
+ const auto infos = translationUnit.tokenInfosInRange(sourceRange(737, 23));
+
+ ASSERT_THAT(infos[3], IsHighlightingMark(737u, 17u, 1u, HighlightingType::LocalVariable));
+ ASSERT_THAT(infos[5], IsHighlightingMark(737u, 20u, 1u, HighlightingType::LocalVariable));
+}
+
Data *TokenProcessor::d;
void TokenProcessor::SetUpTestCase()