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,7 +45,7 @@ bool isWarningOrNote(ClangBackEnd::DiagnosticSeverity severity)
|
|||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isBlackListedDiagnostic(const ClangBackEnd::DiagnosticContainer &diagnostic,
|
bool isBlackListedHeaderDiagnostic(const ClangBackEnd::DiagnosticContainer &diagnostic,
|
||||||
bool isHeaderFile)
|
bool isHeaderFile)
|
||||||
{
|
{
|
||||||
static const Utf8StringVector blackList{
|
static const Utf8StringVector blackList{
|
||||||
@@ -56,6 +56,21 @@ bool isBlackListedDiagnostic(const ClangBackEnd::DiagnosticContainer &diagnostic
|
|||||||
return isHeaderFile && blackList.contains(diagnostic.text());
|
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>
|
template <class Condition>
|
||||||
QVector<ClangBackEnd::DiagnosticContainer>
|
QVector<ClangBackEnd::DiagnosticContainer>
|
||||||
filterDiagnostics(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
filterDiagnostics(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
||||||
@@ -97,7 +112,8 @@ void ClangDiagnosticFilter::filterDocumentRelatedWarnings(
|
|||||||
const auto isLocalWarning = [this, isHeaderFile]
|
const auto isLocalWarning = [this, isHeaderFile]
|
||||||
(const ClangBackEnd::DiagnosticContainer &diagnostic) {
|
(const ClangBackEnd::DiagnosticContainer &diagnostic) {
|
||||||
return isWarningOrNote(diagnostic.severity())
|
return isWarningOrNote(diagnostic.severity())
|
||||||
&& !isBlackListedDiagnostic(diagnostic, isHeaderFile)
|
&& !isBlackListedHeaderDiagnostic(diagnostic, isHeaderFile)
|
||||||
|
&& !isBlackListedQtDiagnostic(diagnostic)
|
||||||
&& diagnostic.location().filePath() == m_filePath;
|
&& diagnostic.location().filePath() == m_filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user