ClangCodeModel: Fix build with MSVC 2022

Change-Id: Ifd0e1e67057e57e4c978784e9634f987edb9dfe4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Christian Kandeler
2021-12-15 18:47:16 +01:00
parent 303f958ee0
commit 3cf51b0cc7
2 changed files with 15 additions and 13 deletions

View File

@@ -2461,7 +2461,7 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
return Range(startPos, endPos); return Range(startPos, endPos);
}; };
const auto isOutputParameter = [&ast, &doc, &tokenRange](const ExpandedSemanticToken &token) { const auto isOutputParameter = [&ast, &doc, &tokenRange](const ExpandedSemanticToken &token) {
if (token.modifiers.contains("usedAsMutableReference")) if (token.modifiers.contains(QLatin1String("usedAsMutableReference")))
return true; return true;
if (token.type != "variable" && token.type != "property" && token.type != "parameter") if (token.type != "variable" && token.type != "property" && token.type != "parameter")
return false; return false;
@@ -2515,16 +2515,17 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
(const ExpandedSemanticToken &token) { (const ExpandedSemanticToken &token) {
TextStyles styles; TextStyles styles;
if (token.type == "variable") { if (token.type == "variable") {
if (token.modifiers.contains("functionScope")) { if (token.modifiers.contains(QLatin1String("functionScope"))) {
styles.mainStyle = C_LOCAL; styles.mainStyle = C_LOCAL;
} else if (token.modifiers.contains("classScope")) { } else if (token.modifiers.contains(QLatin1String("classScope"))) {
styles.mainStyle = C_FIELD; styles.mainStyle = C_FIELD;
} else if (token.modifiers.contains("fileScope") } else if (token.modifiers.contains(QLatin1String("fileScope"))
|| token.modifiers.contains("globalScope")) { || token.modifiers.contains(QLatin1String("globalScope"))) {
styles.mainStyle = C_GLOBAL; styles.mainStyle = C_GLOBAL;
} }
} else if (token.type == "function" || token.type == "method") { } else if (token.type == "function" || token.type == "method") {
styles.mainStyle = token.modifiers.contains("virtual") ? C_VIRTUAL_METHOD : C_FUNCTION; styles.mainStyle = token.modifiers.contains(QLatin1String("virtual"))
? C_VIRTUAL_METHOD : C_FUNCTION;
if (ast.isValid()) { if (ast.isValid()) {
const QList<AstNode> path = getAstPath(ast, tokenRange(token)); const QList<AstNode> path = getAstPath(ast, tokenRange(token));
if (path.length() > 1) { if (path.length() > 1) {
@@ -2582,11 +2583,12 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
} else if (token.type == "typeParameter") { } else if (token.type == "typeParameter") {
// clangd reports both type and non-type template parameters as type parameters, // clangd reports both type and non-type template parameters as type parameters,
// but the latter can be distinguished by the readonly modifier. // but the latter can be distinguished by the readonly modifier.
styles.mainStyle = token.modifiers.contains("readonly") ? C_PARAMETER : C_TYPE; styles.mainStyle = token.modifiers.contains(QLatin1String("readonly"))
? C_PARAMETER : C_TYPE;
} }
if (token.modifiers.contains("declaration")) if (token.modifiers.contains(QLatin1String("declaration")))
styles.mixinStyles.push_back(C_DECLARATION); styles.mixinStyles.push_back(C_DECLARATION);
if (token.modifiers.contains("static")) if (token.modifiers.contains(QLatin1String("static")))
styles.mixinStyles.push_back(C_STATIC_MEMBER); styles.mixinStyles.push_back(C_STATIC_MEMBER);
if (isOutputParameter(token)) if (isOutputParameter(token))
styles.mixinStyles.push_back(C_OUTPUT_ARGUMENT); styles.mixinStyles.push_back(C_OUTPUT_ARGUMENT);

View File

@@ -584,10 +584,10 @@ QStringList createClangOptions(const ProjectPart &projectPart, const QString &fi
// FIXME: Sanitize FileOptionsBuilder instead. // FIXME: Sanitize FileOptionsBuilder instead.
QStringList fileArgs = fileOptions.options(); QStringList fileArgs = fileOptions.options();
if (projectPartOptions.contains("-TP")) if (projectPartOptions.contains(QLatin1String("-TP")))
fileArgs.removeAll("/TP"); fileArgs.removeAll(QLatin1String("/TP"));
if (projectPartOptions.contains("-TC")) if (projectPartOptions.contains(QLatin1String("-TC")))
fileArgs.removeAll("/TC"); fileArgs.removeAll(QLatin1String("/TC"));
return projectPartOptions + fileArgs; return projectPartOptions + fileArgs;
} }