diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2021-04-15 13:54:02 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2021-04-16 07:02:19 +0000 |
commit | c80c724b5294bc02496c7c89a404dd24eefd5413 (patch) | |
tree | a721446fbe3efcf9faa34aa5ccd3c4807ead6edd /tests | |
parent | 8e8236e9e00a6df27ef4632e8fb7cc20cd70e5e8 (diff) |
ClangCodeModel: Fix template highlighting bug
We need to take into account that the ">>" in constructs such as
std::vector<std::pair<int, int>> is only one token on the clang side.
Change-Id: I90f002ca56f236032f6d39c338593a2ff7590061
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unittest/data/highlightingmarks.cpp | 2 | ||||
-rw-r--r-- | tests/unit/unittest/gtest-creator-printing.cpp | 1 | ||||
-rw-r--r-- | tests/unit/unittest/tokenprocessor-test.cpp | 7 |
3 files changed, 10 insertions, 0 deletions
diff --git a/tests/unit/unittest/data/highlightingmarks.cpp b/tests/unit/unittest/data/highlightingmarks.cpp index f3b624f320..8221afc29f 100644 --- a/tests/unit/unittest/data/highlightingmarks.cpp +++ b/tests/unit/unittest/data/highlightingmarks.cpp @@ -769,3 +769,5 @@ template<typename T> void func(T v) { GlobalVar = 5; } + +static std::vector<std::pair<int, int>> pv; diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp index cc10dcfa9d..2f0afc841c 100644 --- a/tests/unit/unittest/gtest-creator-printing.cpp +++ b/tests/unit/unittest/gtest-creator-printing.cpp @@ -868,6 +868,7 @@ static const char *highlightingTypeToCStringLiteral(HighlightingType type) RETURN_TEXT_FOR_CASE(TemplateTemplateParameter); RETURN_TEXT_FOR_CASE(AngleBracketOpen); RETURN_TEXT_FOR_CASE(AngleBracketClose); + RETURN_TEXT_FOR_CASE(DoubleAngleBracketClose); RETURN_TEXT_FOR_CASE(TernaryIf); RETURN_TEXT_FOR_CASE(TernaryElse); } diff --git a/tests/unit/unittest/tokenprocessor-test.cpp b/tests/unit/unittest/tokenprocessor-test.cpp index 94e1b83b15..562f852abe 100644 --- a/tests/unit/unittest/tokenprocessor-test.cpp +++ b/tests/unit/unittest/tokenprocessor-test.cpp @@ -1794,6 +1794,13 @@ TEST_F(TokenProcessor, TemplateSeparateDeclDef) ASSERT_THAT(infos[37], IsHighlightingMark(764u, 5u, 9u, HighlightingType::GlobalVariable)); } +TEST_F(TokenProcessor, NestedTemplate) +{ + const auto infos = translationUnit.tokenInfosInRange(sourceRange(773, 44)); + ASSERT_THAT(infos[12], HasTwoTypes(HighlightingType::Punctuation, + HighlightingType::DoubleAngleBracketClose)); +} + Data *TokenProcessor::d; void TokenProcessor::SetUpTestCase() |