@@ -76,10 +76,10 @@ bool mentionsMainFile(const Diag &D) {
76
76
return false ;
77
77
}
78
78
79
- bool isExcluded (const Diag &D ) {
79
+ bool isExcluded (unsigned DiagID ) {
80
80
// clang will always fail parsing MS ASM, we don't link in desc + asm parser.
81
- if (D. ID == clang::diag::err_msasm_unable_to_create_target ||
82
- D. ID == clang::diag::err_msasm_unsupported_arch)
81
+ if (DiagID == clang::diag::err_msasm_unable_to_create_target ||
82
+ DiagID == clang::diag::err_msasm_unsupported_arch)
83
83
return true ;
84
84
return false ;
85
85
}
@@ -726,44 +726,42 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
726
726
// Handle the new main diagnostic.
727
727
flushLastDiag ();
728
728
729
- if (Adjuster) {
729
+ LastDiag = Diag ();
730
+ // FIXME: Merge with feature modules.
731
+ if (Adjuster)
730
732
DiagLevel = Adjuster (DiagLevel, Info);
731
- if (DiagLevel == DiagnosticsEngine::Ignored) {
732
- LastPrimaryDiagnosticWasSuppressed = true ;
733
- return ;
734
- }
735
- }
736
- LastPrimaryDiagnosticWasSuppressed = false ;
737
733
738
- LastDiag = Diag ();
739
734
FillDiagBase (*LastDiag);
735
+ if (isExcluded (LastDiag->ID ))
736
+ LastDiag->Severity = DiagnosticsEngine::Ignored;
737
+ if (DiagCB)
738
+ DiagCB (Info, *LastDiag);
739
+ // Don't bother filling in the rest if diag is going to be dropped.
740
+ if (LastDiag->Severity == DiagnosticsEngine::Ignored)
741
+ return ;
742
+
740
743
LastDiagLoc.emplace (Info.getLocation (), Info.getSourceManager ());
741
744
LastDiagOriginallyError = OriginallyError;
742
-
743
745
if (!Info.getFixItHints ().empty ())
744
746
AddFix (true /* try to invent a message instead of repeating the diag */ );
745
747
if (Fixer) {
746
- auto ExtraFixes = Fixer (DiagLevel , Info);
748
+ auto ExtraFixes = Fixer (LastDiag-> Severity , Info);
747
749
LastDiag->Fixes .insert (LastDiag->Fixes .end (), ExtraFixes.begin (),
748
750
ExtraFixes.end ());
749
751
}
750
- if (DiagCB)
751
- DiagCB (Info, *LastDiag);
752
752
} else {
753
753
// Handle a note to an existing diagnostic.
754
-
755
- // If a diagnostic was suppressed due to the suppression filter,
756
- // also suppress notes associated with it.
757
- if (LastPrimaryDiagnosticWasSuppressed) {
758
- return ;
759
- }
760
-
761
754
if (!LastDiag) {
762
755
assert (false && " Adding a note without main diagnostic" );
763
756
IgnoreDiagnostics::log (DiagLevel, Info);
764
757
return ;
765
758
}
766
759
760
+ // If a diagnostic was suppressed due to the suppression filter,
761
+ // also suppress notes associated with it.
762
+ if (LastDiag->Severity == DiagnosticsEngine::Ignored)
763
+ return ;
764
+
767
765
if (!Info.getFixItHints ().empty ()) {
768
766
// A clang note with fix-it is not a separate diagnostic in clangd. We
769
767
// attach it as a Fix to the main diagnostic instead.
@@ -788,7 +786,7 @@ void StoreDiags::flushLastDiag() {
788
786
LastDiag.reset ();
789
787
});
790
788
791
- if (isExcluded (* LastDiag) )
789
+ if (LastDiag-> Severity == DiagnosticsEngine::Ignored )
792
790
return ;
793
791
// Move errors that occur from headers into main file.
794
792
if (!LastDiag->InsideMainFile && LastDiagLoc && LastDiagOriginallyError) {
0 commit comments