@@ -517,12 +517,6 @@ class WarningsSpecialCaseList : public llvm::SpecialCaseList {
517
517
const SourceManager &SM) const ;
518
518
519
519
private:
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
-
526
520
llvm::DenseMap<diag::kind, const Section *> DiagToSection;
527
521
};
528
522
} // namespace
@@ -584,43 +578,24 @@ void DiagnosticsEngine::setDiagSuppressionMapping(llvm::MemoryBuffer &Input) {
584
578
bool WarningsSpecialCaseList::isDiagSuppressed (diag::kind DiagId,
585
579
SourceLocation DiagLoc,
586
580
const SourceManager &SM) const {
581
+ PresumedLoc PLoc = SM.getPresumedLoc (DiagLoc);
582
+ if (!PLoc.isValid ())
583
+ return false ;
587
584
const Section *DiagSection = DiagToSection.lookup (DiagId);
588
585
if (!DiagSection)
589
586
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
+ StringRef LongestSup = DiagSection->getLongestMatch (" src" , F, " " );
591
+ if (LongestSup.empty ())
593
592
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
- }
604
593
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;
594
+ StringRef LongestEmit = DiagSection->getLongestMatch (" src" , F, " emit" );
595
+ if (LongestEmit.empty ())
596
+ return true ;
597
+
598
+ return LongestSup.size () > LongestEmit.size ();
624
599
}
625
600
626
601
bool DiagnosticsEngine::isSuppressedViaMapping (diag::kind DiagId,
0 commit comments