@@ -517,12 +517,6 @@ class WarningsSpecialCaseList : public llvm::SpecialCaseList {
517517 const SourceManager &SM) const ;
518518
519519private:
520- // Find the longest glob pattern that matches FilePath amongst
521- // CategoriesToMatchers, return true iff the match exists and belongs to a
522- // positive category.
523- bool globsMatches (const llvm::StringMap<Matcher> &CategoriesToMatchers,
524- StringRef FilePath) const ;
525-
526520 llvm::DenseMap<diag::kind, const Section *> DiagToSection;
527521};
528522} // namespace
@@ -584,43 +578,26 @@ void DiagnosticsEngine::setDiagSuppressionMapping(llvm::MemoryBuffer &Input) {
584578bool WarningsSpecialCaseList::isDiagSuppressed (diag::kind DiagId,
585579 SourceLocation DiagLoc,
586580 const SourceManager &SM) const {
581+ PresumedLoc PLoc = SM.getPresumedLoc (DiagLoc);
582+ if (!PLoc.isValid ())
583+ return false ;
587584 const Section *DiagSection = DiagToSection.lookup (DiagId);
588585 if (!DiagSection)
589586 return false ;
590- const SectionEntries &EntityTypeToCategories = DiagSection->Entries ;
591- auto SrcEntriesIt = EntityTypeToCategories.find (" src" );
592- if (SrcEntriesIt == EntityTypeToCategories.end ())
587+
588+ StringRef F = llvm::sys::path::remove_leading_dotslash (PLoc.getFilename ());
589+
590+ unsigned SuppressLineNo =
591+ llvm::SpecialCaseList::inSectionBlame (DiagSection->Entries , " src" , F, " " );
592+ if (!SuppressLineNo)
593593 return false ;
594- const llvm::StringMap<llvm::SpecialCaseList::Matcher> &CategoriesToMatchers =
595- SrcEntriesIt->getValue ();
596- // We also use presumed locations here to improve reproducibility for
597- // preprocessed inputs.
598- if (PresumedLoc PLoc = SM.getPresumedLoc (DiagLoc); PLoc.isValid ())
599- return globsMatches (
600- CategoriesToMatchers,
601- llvm::sys::path::remove_leading_dotslash (PLoc.getFilename ()));
602- return false ;
603- }
604594
605- bool WarningsSpecialCaseList::globsMatches (
606- const llvm::StringMap<Matcher> &CategoriesToMatchers,
607- StringRef FilePath) const {
608- StringRef LongestMatch;
609- bool LongestIsPositive = false ;
610- for (const auto &Entry : CategoriesToMatchers) {
611- StringRef Category = Entry.getKey ();
612- const llvm::SpecialCaseList::Matcher &Matcher = Entry.getValue ();
613- bool IsPositive = Category != " emit" ;
614- for (const auto &Glob : Matcher.Globs ) {
615- if (Glob->Name .size () < LongestMatch.size ())
616- continue ;
617- if (!Glob->Pattern .match (FilePath))
618- continue ;
619- LongestMatch = Glob->Name ;
620- LongestIsPositive = IsPositive;
621- }
622- }
623- return LongestIsPositive;
595+ unsigned EmitLineNo = llvm::SpecialCaseList::inSectionBlame (
596+ DiagSection->Entries , " src" , F, " emit" );
597+ if (!EmitLineNo)
598+ return true ;
599+
600+ return SuppressLineNo > EmitLineNo;
624601}
625602
626603bool DiagnosticsEngine::isSuppressedViaMapping (diag::kind DiagId,
0 commit comments