forked from qt-creator/qt-creator
Clang: Blacklist override warnings from Q_OBJECT
Task-number: QTCREATORBUG-18621 Change-Id: I20d4fd7a93e0557334135bf7bcbd2f6517a6ede6 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user