Commit ff21d346 authored by Nikolai Kosjar's avatar Nikolai Kosjar

Clang: Blacklist override warnings from Q_OBJECT

Task-number: QTCREATORBUG-18621
Change-Id: I20d4fd7a93e0557334135bf7bcbd2f6517a6ede6
Reviewed-by: Marco Bubke's avatarMarco Bubke <marco.bubke@qt.io>
parent 90de4bae
......@@ -45,8 +45,8 @@ bool isWarningOrNote(ClangBackEnd::DiagnosticSeverity severity)
Q_UNREACHABLE();
}
bool isBlackListedDiagnostic(const ClangBackEnd::DiagnosticContainer &diagnostic,
bool isHeaderFile)
bool isBlackListedHeaderDiagnostic(const ClangBackEnd::DiagnosticContainer &diagnostic,
bool isHeaderFile)
{
static const Utf8StringVector blackList{
Utf8StringLiteral("warning: #pragma once in main file"),
......@@ -56,6 +56,21 @@ bool isBlackListedDiagnostic(const ClangBackEnd::DiagnosticContainer &diagnostic
return isHeaderFile && blackList.contains(diagnostic.text());
}
bool isBlackListedQtDiagnostic(const ClangBackEnd::DiagnosticContainer &diagnostic)
{
static const Utf8StringVector blackList{
// From Q_OBJECT:
Utf8StringLiteral("warning: "
"'metaObject' overrides a member function but is not marked 'override'"),
Utf8StringLiteral("warning: "
"'qt_metacast' overrides a member function but is not marked 'override'"),
Utf8StringLiteral("warning: "
"'qt_metacall' overrides a member function but is not marked 'override'"),
};
return blackList.contains(diagnostic.text());
}
template <class Condition>
QVector<ClangBackEnd::DiagnosticContainer>
filterDiagnostics(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
......@@ -97,7 +112,8 @@ void ClangDiagnosticFilter::filterDocumentRelatedWarnings(
const auto isLocalWarning = [this, isHeaderFile]
(const ClangBackEnd::DiagnosticContainer &diagnostic) {
return isWarningOrNote(diagnostic.severity())
&& !isBlackListedDiagnostic(diagnostic, isHeaderFile)
&& !isBlackListedHeaderDiagnostic(diagnostic, isHeaderFile)
&& !isBlackListedQtDiagnostic(diagnostic)
&& diagnostic.location().filePath() == m_filePath;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment