@@ -537,33 +537,16 @@ WarningsSpecialCaseList::create(const llvm::MemoryBuffer &Input,
537537}
538538
539539void WarningsSpecialCaseList::processSections (DiagnosticsEngine &Diags) {
540- // Drop the default section introduced by special case list, we only support
541- // exact diagnostic group names.
542- // FIXME: We should make this configurable in the parser instead.
543- // FIXME: C++20 can use std::erase_if(Sections, [](Section &sec) { return
544- // sec.SectionStr == "*"; });
545- llvm::erase_if (Sections, [](Section &sec) { return sec.SectionStr == " *" ; });
546- // Make sure we iterate sections by their line numbers.
547- std::vector<std::pair<unsigned , const Section *>> LineAndSectionEntry;
548- LineAndSectionEntry.reserve (Sections.size ());
549- for (const auto &Entry : Sections) {
550- StringRef DiagName = Entry.SectionStr ;
551- // Each section has a matcher with that section's name, attached to that
552- // line.
553- const auto &DiagSectionMatcher = Entry.SectionMatcher ;
554- unsigned DiagLine = 0 ;
555- for (const auto &Glob : DiagSectionMatcher->Globs )
556- if (Glob->Name == DiagName) {
557- DiagLine = Glob->LineNo ;
558- break ;
559- }
560- LineAndSectionEntry.emplace_back (DiagLine, &Entry);
561- }
562- llvm::sort (LineAndSectionEntry);
563540 static constexpr auto WarningFlavor = clang::diag::Flavor::WarningOrError;
564- for (const auto &[_, SectionEntry] : LineAndSectionEntry) {
541+ for (const auto &SectionEntry : Sections) {
542+ StringRef DiagGroup = SectionEntry.SectionStr ;
543+ if (DiagGroup == " *" ) {
544+ // Drop the default section introduced by special case list, we only
545+ // support exact diagnostic group names.
546+ // FIXME: We should make this configurable in the parser instead.
547+ continue ;
548+ }
565549 SmallVector<diag::kind> GroupDiags;
566- StringRef DiagGroup = SectionEntry->SectionStr ;
567550 if (Diags.getDiagnosticIDs ()->getDiagnosticsInGroup (
568551 WarningFlavor, DiagGroup, GroupDiags)) {
569552 StringRef Suggestion =
@@ -576,7 +559,7 @@ void WarningsSpecialCaseList::processSections(DiagnosticsEngine &Diags) {
576559 for (diag::kind Diag : GroupDiags)
577560 // We're intentionally overwriting any previous mappings here to make sure
578561 // latest one takes precedence.
579- DiagToSection[Diag] = SectionEntry;
562+ DiagToSection[Diag] = & SectionEntry;
580563 }
581564}
582565
0 commit comments