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>
This commit is contained in:
Christian Kandeler
2020-10-23 16:37:59 +02:00
parent 9c0544c386
commit 2b32b2e440
3 changed files with 14 additions and 0 deletions

View File

@@ -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:

View File

@@ -731,3 +731,8 @@ class Property {
)
};
void structuredBindingTest() {
const int a[] = {1, 2};
const auto [x, y] = a;
}

View File

@@ -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()