ClangCodeModel: Suppress "Unknown argument" error

Unknown compiler flags are an unsuppressable error in clang.
But we do not want to maintain a blacklist of unsupported GCC and MSVC
options or a whitelist of supported clang options, as both would
constantly go out of date.
As clangd seems to work fine despite the error message, we simply filter
out this type of diagnostic.

Fixes: QTCREATORBUG-27113
Change-Id: Ib32601831eded60daf80eb0ca5cf01bbd71493fa
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-02-25 16:37:16 +01:00
parent f8cec0a85a
commit 9735049e2c
10 changed files with 26 additions and 9 deletions

View File

@@ -1321,7 +1321,12 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
return new ClangdTextMark(filePath, diag, isProjectFile, this);
};
const auto hideDiagsHandler = []{ ClangDiagnosticManager::clearTaskHubIssues(); };
setDiagnosticsHandlers(textMarkCreator, hideDiagsHandler);
static const auto diagsFilter = [](const Diagnostic &diag) {
const Diagnostic::Code code = diag.code().value_or(Diagnostic::Code());
const QString * const codeString = Utils::get_if<QString>(&code);
return !codeString || *codeString != "drv_unknown_argument";
};
setDiagnosticsHandlers(textMarkCreator, hideDiagsHandler, diagsFilter);
setSymbolStringifier(displayNameFromDocumentSymbol);
setSemanticTokensHandler([this](TextDocument *doc, const QList<ExpandedSemanticToken> &tokens,
int version, bool force) {

View File

@@ -27,5 +27,7 @@ SOURCES = \
privateFuncDefCompletion.cpp \
signalCompletion.cpp
QMAKE_CXXFLAGS += -ffoo
HEADERS = mainwindow.h
FORMS = mainwindow.ui

View File

@@ -2,3 +2,4 @@ TEMPLATE = app
QT = core
HEADERS = defs.h
SOURCES = main.cpp
QMAKE_CXXFLAGS += -ffoo

View File

@@ -2,3 +2,4 @@ TEMPLATE = app
CONFIG -= qt
HEADERS = cursor.h header.h
SOURCES = cursor.cpp main.cpp
QMAKE_CXXFLAGS += -ffoo

View File

@@ -1,3 +1,4 @@
TEMPLATE = app
CONFIG -= qt
SOURCES = highlighting.cpp
QMAKE_CXXFLAGS += -ffoo

View File

@@ -1,5 +1,4 @@
TEMPLATE = app
CONFIG -= qt
SOURCES = references.cpp
QMAKE_CXXFLAGS += -ffoo