aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-09-08 15:48:52 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-09-14 11:42:09 +0000
commitd14be7493f8ed963840d198315ef46b4641427bd (patch)
tree250caa3006f7c2df49688d6df382e159eaaa0070
parent226982b7b026fea5f8e8cf36da2e544de882b6e2 (diff)
ClangBackEnd: Support highlighting of alias templates
Fixes: QTCREATORBUG-24552 Change-Id: I80d2b16114234cf896173cd4104e6a5f12009f69 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/tools/clangbackend/source/tokeninfo.cpp1
-rw-r--r--tests/unit/unittest/data/highlightingmarks.cpp4
-rw-r--r--tests/unit/unittest/tokenprocessor-test.cpp7
-rw-r--r--tests/unit/unittest/unittest.pro10
-rw-r--r--tests/unit/unittest/unittest.qbs6
5 files changed, 20 insertions, 8 deletions
diff --git a/src/tools/clangbackend/source/tokeninfo.cpp b/src/tools/clangbackend/source/tokeninfo.cpp
index de40a954e1..47b8188986 100644
--- a/src/tools/clangbackend/source/tokeninfo.cpp
+++ b/src/tools/clangbackend/source/tokeninfo.cpp
@@ -317,6 +317,7 @@ void TokenInfo::typeKind(const Cursor &cursor)
m_types.mixinHighlightingTypes.push_back(HighlightingType::Namespace);
return;
case CXCursor_TypeAliasDecl:
+ case CXCursor_TypeAliasTemplateDecl:
m_types.mixinHighlightingTypes.push_back(HighlightingType::TypeAlias);
return;
case CXCursor_TypedefDecl:
diff --git a/tests/unit/unittest/data/highlightingmarks.cpp b/tests/unit/unittest/data/highlightingmarks.cpp
index a703e89a11..2476cabfb2 100644
--- a/tests/unit/unittest/data/highlightingmarks.cpp
+++ b/tests/unit/unittest/data/highlightingmarks.cpp
@@ -695,3 +695,7 @@ protected:
private:
static int privateValue;
};
+
+template <int i, int j> struct S { };
+template <int i> using spec = S<i, 1>;
+spec<2> s;
diff --git a/tests/unit/unittest/tokenprocessor-test.cpp b/tests/unit/unittest/tokenprocessor-test.cpp
index 285c6d3446..786b980f22 100644
--- a/tests/unit/unittest/tokenprocessor-test.cpp
+++ b/tests/unit/unittest/tokenprocessor-test.cpp
@@ -1722,6 +1722,13 @@ TEST_F(TokenProcessor, StaticPrivateMember)
ASSERT_THAT(container.extraInfo.accessSpecifier, ClangBackEnd::AccessSpecifier::Private);
}
+TEST_F(TokenProcessor, TemplateAlias)
+{
+ const auto infos = translationUnit.tokenInfosInRange(sourceRange(701, 8));
+
+ ASSERT_THAT(infos[0], HasTwoTypes(HighlightingType::Type, HighlightingType::TypeAlias));
+}
+
Data *TokenProcessor::d;
void TokenProcessor::SetUpTestCase()
diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro
index 3917237d0b..4b3254a4d2 100644
--- a/tests/unit/unittest/unittest.pro
+++ b/tests/unit/unittest/unittest.pro
@@ -174,12 +174,14 @@ SOURCES += \
diagnosticset-test.cpp \
diagnostic-test.cpp \
fixit-test.cpp \
+ gtest-clang-printing.cpp \
highlightingresultreporter-test.cpp \
senddocumenttracker-test.cpp \
skippedsourceranges-test.cpp \
sourcelocation-test.cpp \
sourcerange-test.cpp \
token-test.cpp \
+ tokenprocessor-test.cpp \
translationunitupdater-test.cpp \
unsavedfiles-test.cpp \
unsavedfile-test.cpp \
@@ -201,7 +203,6 @@ SOURCES += \
clangqueryprojectfindfilter-test.cpp \
clangquery-test.cpp \
clangreferencescollector-test.cpp \
- gtest-clang-printing.cpp \
pchcreator-test.cpp \
refactoringclientserverinprocess-test.cpp \
refactoringclient-test.cpp \
@@ -212,8 +213,7 @@ SOURCES += \
symbolscollector-test.cpp \
testclangtool.cpp \
usedmacrocollector-test.cpp \
- builddependencycollector-test.cpp \
- tokenprocessor-test.cpp
+ builddependencycollector-test.cpp
!isEmpty(QTC_UNITTEST_BUILD_CPP_PARSER):SOURCES += refactoringengine-test.cpp
@@ -311,14 +311,14 @@ HEADERS += \
clangasyncjob-base.h \
clangcompareoperators.h \
diagnosticcontainer-matcher.h \
+ gtest-clang-printing.h
}
!isEmpty(LIBTOOLING_LIBS) {
HEADERS += \
- gtest-clang-printing.h \
mockrefactoringclient.h \
mockrefactoringserver.h \
- testclangtool.h \
+ testclangtool.h
}
OTHER_FILES += $$files(data/*) $$files(data/include/*)
diff --git a/tests/unit/unittest/unittest.qbs b/tests/unit/unittest/unittest.qbs
index 43cfc86eed..4e5a7993e4 100644
--- a/tests/unit/unittest/unittest.qbs
+++ b/tests/unit/unittest/unittest.qbs
@@ -323,6 +323,8 @@ CppApplication {
"diagnosticcontainer-matcher.h",
"diagnosticset-test.cpp",
"fixit-test.cpp",
+ "gtest-clang-printing.cpp",
+ "gtest-clang-printing.h",
"highlightingresultreporter-test.cpp",
"readexporteddiagnostics-test.cpp",
"senddocumenttracker-test.cpp",
@@ -330,6 +332,7 @@ CppApplication {
"sourcelocation-test.cpp",
"sourcerange-test.cpp",
"token-test.cpp",
+ "tokenprocessor-test.cpp",
"translationunitupdater-test.cpp",
"unsavedfile-test.cpp",
"unsavedfiles-test.cpp",
@@ -347,8 +350,6 @@ CppApplication {
"clangquerygatherer-test.cpp",
"clangqueryprojectfindfilter-test.cpp",
"clangreferencescollector-test.cpp",
- "gtest-clang-printing.cpp",
- "gtest-clang-printing.h",
"gtest-llvm-printing.cpp",
"mockrefactoringclient.h",
"mockrefactoringserver.h",
@@ -363,7 +364,6 @@ CppApplication {
"symbolscollector-test.cpp",
"testclangtool.cpp",
"testclangtool.h",
- "tokenprocessor-test.cpp",
"usedmacrocollector-test.cpp",
]
}