forked from qt-creator/qt-creator
Clang: Suppress diagnostic "file 'x' from the precompiled header has been overridden"
...since it's not critical, only annoying to see. If this diagnostic occurs, changes in a non-project header will not be reflected in the main file. That's not a common case. Task-number: QTCREATORBUG-20125 Change-Id: Ic7b65506cdd6bc1c163050497d6f7c106a48d517 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -234,6 +234,17 @@ static bool isHeaderErrorDiagnostic(const Utf8String &mainFilePath, const Diagno
|
||||
return isCritical && diagnostic.location().filePath() != mainFilePath;
|
||||
}
|
||||
|
||||
static bool isIgnoredHeaderErrorDiagnostic(const Diagnostic &diagnostic)
|
||||
{
|
||||
// FIXME: This diagnostic can appear if e.g. a main file includes a -isystem header and then the
|
||||
// header is opened in the editor - the provided unsaved file for the newly opened editor
|
||||
// overrides the file from the preamble. In this case, clang uses the version from the preamble
|
||||
// and changes in the header are not reflected in the main file. Typically that's not a problem
|
||||
// because only non-project headers are opened as -isystem headers.
|
||||
return diagnostic.text().endsWith(
|
||||
Utf8StringLiteral("from the precompiled header has been overridden"));
|
||||
}
|
||||
|
||||
void TranslationUnit::extractDiagnostics(DiagnosticContainer &firstHeaderErrorDiagnostic,
|
||||
QVector<DiagnosticContainer> &mainFileDiagnostics) const
|
||||
{
|
||||
@@ -243,7 +254,9 @@ void TranslationUnit::extractDiagnostics(DiagnosticContainer &firstHeaderErrorDi
|
||||
bool hasFirstHeaderErrorDiagnostic = false;
|
||||
|
||||
for (const Diagnostic &diagnostic : diagnostics()) {
|
||||
if (!hasFirstHeaderErrorDiagnostic && isHeaderErrorDiagnostic(m_filePath, diagnostic)) {
|
||||
if (!hasFirstHeaderErrorDiagnostic
|
||||
&& isHeaderErrorDiagnostic(m_filePath, diagnostic)
|
||||
&& !isIgnoredHeaderErrorDiagnostic(diagnostic)) {
|
||||
hasFirstHeaderErrorDiagnostic = true;
|
||||
firstHeaderErrorDiagnostic = diagnostic.toDiagnosticContainer();
|
||||
}
|
||||
|
Reference in New Issue
Block a user