From 72c1c891fa0ee374d0d77c4918617a6968b5fcba Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 4 Aug 2022 15:17:26 +0200 Subject: [PATCH] ClangCodeModel: Adapt to new highlighting modifier in clangd See https://reviews.llvm.org/D134728. Change-Id: I2bcfb09736b6eabc54cd986b0c096c8fa5869b8e Reviewed-by: Qt CI Bot Reviewed-by: Reviewed-by: David Schulz --- src/plugins/clangcodemodel/clangdsemantichighlighting.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plugins/clangcodemodel/clangdsemantichighlighting.cpp b/src/plugins/clangcodemodel/clangdsemantichighlighting.cpp index 6714c91b04a..fbddb0b605a 100644 --- a/src/plugins/clangcodemodel/clangdsemantichighlighting.cpp +++ b/src/plugins/clangcodemodel/clangdsemantichighlighting.cpp @@ -289,10 +289,9 @@ void doSemanticHighlighting( } } else if (token.type == "class") { styles.mainStyle = C_TYPE; - - // clang hardly ever differentiates between constructors and the associated class, - // whereas we highlight constructors as functions. - if (ast.isValid()) { + if (token.modifiers.contains("constructorOrDestructor")) { + styles.mainStyle = C_FUNCTION; + } else if (ver < 16 && ast.isValid()) { const ClangdAstPath path = getAstPath(ast, tokenRange(token)); if (!path.isEmpty()) { if (path.last().kind() == "CXXConstructor") {