зеркало из https://github.com/microsoft/clang-1.git
Move the check whether a diagnostic must be ignored because it is in a system header
inside DiagnosticIDs::getDiagnosticLevel. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129950 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
46f1110b32
Коммит
cfdadfe547
|
@ -470,6 +470,19 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass,
|
|||
if (Diag.AllExtensionsSilenced && isBuiltinExtensionDiag(DiagID))
|
||||
return DiagnosticIDs::Ignored;
|
||||
|
||||
// If we are in a system header, we ignore it.
|
||||
// We also want to ignore extensions and warnings in -Werror and
|
||||
// -pedantic-errors modes, which *map* warnings/extensions to errors.
|
||||
if (Result >= DiagnosticIDs::Warning &&
|
||||
DiagClass != CLASS_ERROR &&
|
||||
// Custom diagnostics always are emitted in system headers.
|
||||
DiagID < diag::DIAG_UPPER_LIMIT &&
|
||||
Diag.SuppressSystemWarnings &&
|
||||
Loc.isValid() &&
|
||||
Diag.getSourceManager().isInSystemHeader(
|
||||
Diag.getSourceManager().getInstantiationLoc(Loc)))
|
||||
return DiagnosticIDs::Ignored;
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
@ -555,16 +568,9 @@ bool DiagnosticIDs::ProcessDiag(Diagnostic &Diag) const {
|
|||
DiagnosticIDs::Level DiagLevel;
|
||||
unsigned DiagID = Info.getID();
|
||||
|
||||
// ShouldEmitInSystemHeader - True if this diagnostic should be produced even
|
||||
// in a system header.
|
||||
bool ShouldEmitInSystemHeader;
|
||||
|
||||
if (DiagID >= diag::DIAG_UPPER_LIMIT) {
|
||||
// Handle custom diagnostics, which cannot be mapped.
|
||||
DiagLevel = CustomDiagInfo->getLevel(DiagID);
|
||||
|
||||
// Custom diagnostics always are emitted in system headers.
|
||||
ShouldEmitInSystemHeader = true;
|
||||
} else {
|
||||
// Get the class of the diagnostic. If this is a NOTE, map it onto whatever
|
||||
// the diagnostic level was for the previous diagnostic so that it is
|
||||
|
@ -572,14 +578,7 @@ bool DiagnosticIDs::ProcessDiag(Diagnostic &Diag) const {
|
|||
unsigned DiagClass = getBuiltinDiagClass(DiagID);
|
||||
if (DiagClass == CLASS_NOTE) {
|
||||
DiagLevel = DiagnosticIDs::Note;
|
||||
ShouldEmitInSystemHeader = false; // extra consideration is needed
|
||||
} else {
|
||||
// If this is not an error and we are in a system header, we ignore it.
|
||||
// Check the original Diag ID here, because we also want to ignore
|
||||
// extensions and warnings in -Werror and -pedantic-errors modes, which
|
||||
// *map* warnings/extensions to errors.
|
||||
ShouldEmitInSystemHeader = DiagClass == CLASS_ERROR;
|
||||
|
||||
DiagLevel = getDiagnosticLevel(DiagID, DiagClass, Info.getLocation(),
|
||||
Diag);
|
||||
}
|
||||
|
@ -615,18 +614,6 @@ bool DiagnosticIDs::ProcessDiag(Diagnostic &Diag) const {
|
|||
Diag.LastDiagLevel == DiagnosticIDs::Ignored))
|
||||
return false;
|
||||
|
||||
// If this diagnostic is in a system header and is not a clang error, suppress
|
||||
// it.
|
||||
if (Diag.SuppressSystemWarnings && !ShouldEmitInSystemHeader &&
|
||||
Info.getLocation().isValid() &&
|
||||
Diag.getSourceManager().isInSystemHeader(
|
||||
Diag.getSourceManager().getInstantiationLoc(Info.getLocation())) &&
|
||||
(DiagLevel != DiagnosticIDs::Note ||
|
||||
Diag.LastDiagLevel == DiagnosticIDs::Ignored)) {
|
||||
Diag.LastDiagLevel = DiagnosticIDs::Ignored;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DiagLevel >= DiagnosticIDs::Error) {
|
||||
if (Diag.Client->IncludeInDiagnosticCounts()) {
|
||||
Diag.ErrorOccurred = true;
|
||||
|
|
Загрузка…
Ссылка в новой задаче