Skip to content

Commit 534d49d

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.6
1 parent 99779b4 commit 534d49d

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

clang/lib/Basic/Diagnostic.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,10 @@ void WarningsSpecialCaseList::processSections(DiagnosticsEngine &Diags) {
553553
// Each section has a matcher with that section's name, attached to that
554554
// line.
555555
const auto &DiagSectionMatcher = Entry.SectionMatcher;
556-
unsigned DiagLine = DiagSectionMatcher->Globs.at(DiagName).second;
556+
unsigned DiagLine = 0;
557+
for (const auto &[Pattern, Pair] : DiagSectionMatcher->Globs)
558+
if (Pattern == DiagName)
559+
DiagLine = Pair.second;
557560
LineAndSectionEntry.emplace_back(DiagLine, &Entry);
558561
}
559562
llvm::sort(LineAndSectionEntry);

llvm/include/llvm/Support/SpecialCaseList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class SpecialCaseList {
125125
// Returns zero if no match is found.
126126
LLVM_ABI unsigned match(StringRef Query) const;
127127

128-
StringMap<std::pair<GlobPattern, unsigned>> Globs;
128+
std::vector<std::pair<std::string, std::pair<GlobPattern, unsigned>>> Globs;
129129
std::vector<std::pair<std::unique_ptr<Regex>, unsigned>> RegExes;
130130
};
131131

llvm/lib/Support/SpecialCaseList.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,16 @@ Error SpecialCaseList::Matcher::insert(StringRef Pattern, unsigned LineNumber,
5353
return Error::success();
5454
}
5555

56-
auto [It, DidEmplace] = Globs.try_emplace(Pattern);
57-
if (DidEmplace) {
58-
// We must be sure to use the string in the map rather than the provided
59-
// reference which could be destroyed before match() is called
60-
Pattern = It->getKey();
61-
auto &Pair = It->getValue();
62-
if (auto Err = GlobPattern::create(Pattern, /*MaxSubPatterns=*/1024)
63-
.moveInto(Pair.first))
64-
return Err;
65-
Pair.second = LineNumber;
66-
}
56+
Globs.emplace_back();
57+
auto &Glob = Globs.back();
58+
Glob.first = Pattern;
59+
auto &Pair = Glob.second;
60+
// We must be sure to use the string in the map rather than the provided
61+
// reference which could be destroyed before match() is called
62+
if (auto Err = GlobPattern::create(Glob.first, /*MaxSubPatterns=*/1024)
63+
.moveInto(Pair.first))
64+
return Err;
65+
Pair.second = LineNumber;
6766
return Error::success();
6867
}
6968

0 commit comments

Comments
 (0)