forked from qt-creator/qt-creator
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:
@@ -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:
|
||||
|
||||
@@ -731,3 +731,8 @@ class Property {
|
||||
|
||||
)
|
||||
};
|
||||
|
||||
void structuredBindingTest() {
|
||||
const int a[] = {1, 2};
|
||||
const auto [x, y] = a;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user