@@ -542,26 +542,32 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc,
542542 return Result;
543543
544544 const auto &SM = Diag.getSourceManager ();
545-
546- bool ShowInSystemHeader =
547- IsCustomDiag
548- ? CustomDiagInfo->getDescription (DiagID).ShouldShowInSystemHeader ()
549- : !GetDiagInfo (DiagID) || GetDiagInfo (DiagID)->WarnShowInSystemHeader ;
550-
551545 // If we are in a system header, we ignore it. We look at the diagnostic class
552546 // because we also want to ignore extensions and warnings in -Werror and
553547 // -pedantic-errors modes, which *map* warnings/extensions to errors.
554- if (State->SuppressSystemWarnings && !ShowInSystemHeader && Loc.isValid () &&
555- SM.isInSystemHeader (SM.getExpansionLoc (Loc)))
556- return diag::Severity::Ignored;
557-
548+ if (State->SuppressSystemWarnings && Loc.isValid () &&
549+ SM.isInSystemHeader (SM.getExpansionLoc (Loc))) {
550+ bool ShowInSystemHeader = true ;
551+ if (IsCustomDiag)
552+ ShowInSystemHeader =
553+ CustomDiagInfo->getDescription (DiagID).ShouldShowInSystemHeader ();
554+ else if (const StaticDiagInfoRec *Rec = GetDiagInfo (DiagID))
555+ ShowInSystemHeader = Rec->WarnShowInSystemHeader ;
556+
557+ if (!ShowInSystemHeader)
558+ return diag::Severity::Ignored;
559+ }
558560 // We also ignore warnings due to system macros
559- bool ShowInSystemMacro =
560- !GetDiagInfo (DiagID) || GetDiagInfo (DiagID)->WarnShowInSystemMacro ;
561- if (State->SuppressSystemWarnings && !ShowInSystemMacro && Loc.isValid () &&
562- SM.isInSystemMacro (Loc))
563- return diag::Severity::Ignored;
561+ if (State->SuppressSystemWarnings && Loc.isValid () &&
562+ SM.isInSystemMacro (Loc)) {
563+
564+ bool ShowInSystemMacro = true ;
565+ if (const StaticDiagInfoRec *Rec = GetDiagInfo (DiagID))
566+ ShowInSystemMacro = Rec->WarnShowInSystemMacro ;
564567
568+ if (!ShowInSystemMacro)
569+ return diag::Severity::Ignored;
570+ }
565571 // Clang-diagnostics pragmas always take precedence over suppression mapping.
566572 if (!Mapping.isPragma () && Diag.isSuppressedViaMapping (DiagID, Loc))
567573 return diag::Severity::Ignored;
0 commit comments