@@ -533,24 +533,28 @@ void WarningsSpecialCaseList::processSections(DiagnosticsEngine &Diags) {
533533 // Drop the default section introduced by special case list, we only support
534534 // exact diagnostic group names.
535535 // FIXME: We should make this configurable in the parser instead.
536- Sections.erase (" *" );
536+ // FIXME: C++20 can use std::erase_if(Sections, [](Section &sec) { return
537+ // sec.SectionStr == "*"; });
538+ Sections.erase (
539+ std::remove_if (Sections.begin (), Sections.end (),
540+ [](Section &sec) { return sec.SectionStr == " *" ; }),
541+ Sections.end ());
537542 // Make sure we iterate sections by their line numbers.
538- std::vector<std::pair<unsigned , const llvm::StringMapEntry<Section> *>>
539- LineAndSectionEntry;
543+ std::vector<std::pair<unsigned , const Section *>> LineAndSectionEntry;
540544 LineAndSectionEntry.reserve (Sections.size ());
541545 for (const auto &Entry : Sections) {
542- StringRef DiagName = Entry.getKey () ;
546+ StringRef DiagName = Entry.SectionStr ;
543547 // Each section has a matcher with that section's name, attached to that
544548 // line.
545- const auto &DiagSectionMatcher = Entry.getValue (). SectionMatcher ;
549+ const auto &DiagSectionMatcher = Entry.SectionMatcher ;
546550 unsigned DiagLine = DiagSectionMatcher->Globs .at (DiagName).second ;
547551 LineAndSectionEntry.emplace_back (DiagLine, &Entry);
548552 }
549553 llvm::sort (LineAndSectionEntry);
550554 static constexpr auto WarningFlavor = clang::diag::Flavor::WarningOrError;
551555 for (const auto &[_, SectionEntry] : LineAndSectionEntry) {
552556 SmallVector<diag::kind> GroupDiags;
553- StringRef DiagGroup = SectionEntry->getKey () ;
557+ StringRef DiagGroup = SectionEntry->SectionStr ;
554558 if (Diags.getDiagnosticIDs ()->getDiagnosticsInGroup (
555559 WarningFlavor, DiagGroup, GroupDiags)) {
556560 StringRef Suggestion =
@@ -563,7 +567,7 @@ void WarningsSpecialCaseList::processSections(DiagnosticsEngine &Diags) {
563567 for (diag::kind Diag : GroupDiags)
564568 // We're intentionally overwriting any previous mappings here to make sure
565569 // latest one takes precedence.
566- DiagToSection[Diag] = & SectionEntry-> getValue () ;
570+ DiagToSection[Diag] = SectionEntry;
567571 }
568572}
569573
0 commit comments