aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tools/clangbackend/source/tokeninfo.cpp1
-rw-r--r--tests/unit/unittest/data/highlightingmarks.cpp5
-rw-r--r--tests/unit/unittest/tokenprocessor-test.cpp8
3 files changed, 14 insertions, 0 deletions
diff --git a/src/tools/clangbackend/source/tokeninfo.cpp b/src/tools/clangbackend/source/tokeninfo.cpp
index 47b8188986..6b2e56c8ac 100644
--- a/src/tools/clangbackend/source/tokeninfo.cpp
+++ b/src/tools/clangbackend/source/tokeninfo.cpp
@@ -374,6 +374,7 @@ void TokenInfo::identifierKind(const Cursor &cursor, Recursion recursion)
case CXCursor_ParmDecl:
case CXCursor_VarDecl:
case CXCursor_VariableRef:
+ case CXCursor_UnexposedDecl: // structured bindings; see https://reviews.llvm.org/D78213
variableKind(cursor.referenced());
break;
case CXCursor_DeclRefExpr:
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()