@@ -525,12 +525,6 @@ class WarningsSpecialCaseList : public llvm::SpecialCaseList {
525
525
const SourceManager &SM) const ;
526
526
527
527
private:
528
- // Find the longest glob pattern that matches FilePath amongst
529
- // CategoriesToMatchers, return true iff the match exists and belongs to a
530
- // positive category.
531
- bool globsMatches (const llvm::StringMap<Matcher> &CategoriesToMatchers,
532
- StringRef FilePath) const ;
533
-
534
528
llvm::DenseMap<diag::kind, const Section *> DiagToSection;
535
529
};
536
530
} // namespace
@@ -592,43 +586,24 @@ void DiagnosticsEngine::setDiagSuppressionMapping(llvm::MemoryBuffer &Input) {
592
586
bool WarningsSpecialCaseList::isDiagSuppressed (diag::kind DiagId,
593
587
SourceLocation DiagLoc,
594
588
const SourceManager &SM) const {
589
+ PresumedLoc PLoc = SM.getPresumedLoc (DiagLoc);
590
+ if (!PLoc.isValid ())
591
+ return false ;
595
592
const Section *DiagSection = DiagToSection.lookup (DiagId);
596
593
if (!DiagSection)
597
594
return false ;
598
- const SectionEntries &EntityTypeToCategories = DiagSection->Entries ;
599
- auto SrcEntriesIt = EntityTypeToCategories.find (" src" );
600
- if (SrcEntriesIt == EntityTypeToCategories.end ())
595
+
596
+ StringRef F = llvm::sys::path::remove_leading_dotslash (PLoc.getFilename ());
597
+
598
+ StringRef LongestSup = DiagSection->getLongestMatch (" src" , F, " " );
599
+ if (LongestSup.empty ())
601
600
return false ;
602
- const llvm::StringMap<llvm::SpecialCaseList::Matcher> &CategoriesToMatchers =
603
- SrcEntriesIt->getValue ();
604
- // We also use presumed locations here to improve reproducibility for
605
- // preprocessed inputs.
606
- if (PresumedLoc PLoc = SM.getPresumedLoc (DiagLoc); PLoc.isValid ())
607
- return globsMatches (
608
- CategoriesToMatchers,
609
- llvm::sys::path::remove_leading_dotslash (PLoc.getFilename ()));
610
- return false ;
611
- }
612
601
613
- bool WarningsSpecialCaseList::globsMatches (
614
- const llvm::StringMap<Matcher> &CategoriesToMatchers,
615
- StringRef FilePath) const {
616
- StringRef LongestMatch;
617
- bool LongestIsPositive = false ;
618
- for (const auto &Entry : CategoriesToMatchers) {
619
- StringRef Category = Entry.getKey ();
620
- const llvm::SpecialCaseList::Matcher &Matcher = Entry.getValue ();
621
- bool IsPositive = Category != " emit" ;
622
- for (const auto &Glob : Matcher.Globs ) {
623
- if (Glob->Name .size () < LongestMatch.size ())
624
- continue ;
625
- if (!Glob->Pattern .match (FilePath))
626
- continue ;
627
- LongestMatch = Glob->Name ;
628
- LongestIsPositive = IsPositive;
629
- }
630
- }
631
- return LongestIsPositive;
602
+ StringRef LongestEmit = DiagSection->getLongestMatch (" src" , F, " emit" );
603
+ if (LongestEmit.empty ())
604
+ return true ;
605
+
606
+ return LongestSup.size () > LongestEmit.size ();
632
607
}
633
608
634
609
bool DiagnosticsEngine::isSuppressedViaMapping (diag::kind DiagId,
0 commit comments