Skip to content

Commit b0aa1c4

Browse files
committed
[𝘀𝗽𝗿] changes to main this commit is based on
Created using spr 1.3.6 [skip ci]
1 parent 009da92 commit b0aa1c4

File tree

4 files changed

+15
-30
lines changed

4 files changed

+15
-30
lines changed

clang/lib/Basic/Diagnostic.cpp

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -537,33 +537,16 @@ WarningsSpecialCaseList::create(const llvm::MemoryBuffer &Input,
537537
}
538538

539539
void 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

clang/lib/Basic/SanitizerSpecialCaseList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void SanitizerSpecialCaseList::createSanitizerSections() {
4242
SanitizerMask Mask;
4343

4444
#define SANITIZER(NAME, ID) \
45-
if (S.SectionMatcher->match(NAME)) \
45+
if (S.SectionMatcher.match(NAME)) \
4646
Mask |= SanitizerKind::ID;
4747
#define SANITIZER_GROUP(NAME, ID, ALIAS) SANITIZER(NAME, ID)
4848

llvm/include/llvm/Support/SpecialCaseList.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ class SpecialCaseList {
147147
Section(StringRef Str, unsigned FileIdx)
148148
: SectionStr(Str), FileIdx(FileIdx) {};
149149

150-
std::unique_ptr<Matcher> SectionMatcher = std::make_unique<Matcher>();
150+
Section(Section &&) = default;
151+
152+
Matcher SectionMatcher;
151153
SectionEntries Entries;
152154
std::string SectionStr;
153155
unsigned FileIdx;

llvm/lib/Support/SpecialCaseList.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ SpecialCaseList::addSection(StringRef SectionStr, unsigned FileNo,
135135
Sections.emplace_back(SectionStr, FileNo);
136136
auto &Section = Sections.back();
137137

138-
if (auto Err = Section.SectionMatcher->insert(SectionStr, LineNo, UseGlobs)) {
138+
if (auto Err = Section.SectionMatcher.insert(SectionStr, LineNo, UseGlobs)) {
139139
return createStringError(errc::invalid_argument,
140140
"malformed section at line " + Twine(LineNo) +
141141
": '" + SectionStr +
@@ -218,7 +218,7 @@ std::pair<unsigned, unsigned>
218218
SpecialCaseList::inSectionBlame(StringRef Section, StringRef Prefix,
219219
StringRef Query, StringRef Category) const {
220220
for (const auto &S : reverse(Sections)) {
221-
if (S.SectionMatcher->match(Section)) {
221+
if (S.SectionMatcher.match(Section)) {
222222
unsigned Blame = inSectionBlame(S.Entries, Prefix, Query, Category);
223223
if (Blame)
224224
return {S.FileIdx, Blame};

0 commit comments

Comments
 (0)