Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clang/lib/Basic/SanitizerSpecialCaseList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ SanitizerSpecialCaseList::inSectionBlame(SanitizerMask Mask, StringRef Prefix,
StringRef Category) const {
for (const auto &S : llvm::reverse(SanitizerSections)) {
if (S.Mask & Mask) {
unsigned LineNum =
SpecialCaseList::inSectionBlame(S.S.Entries, Prefix, Query, Category);
unsigned LineNum = S.S.getLastMatch(Prefix, Query, Category);
if (LineNum > 0)
return {S.S.FileIdx, LineNum};
}
Expand Down
11 changes: 5 additions & 6 deletions llvm/include/llvm/Support/SpecialCaseList.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ class SpecialCaseList {
SectionEntries Entries;
std::string SectionStr;
unsigned FileIdx;

// Helper method to search by Prefix, Query, and Category. Returns
// 1-based line number on which rule is defined, or 0 if there is no match.
LLVM_ABI unsigned getLastMatch(StringRef Prefix, StringRef Query,
StringRef Category) const;
};

std::vector<Section> Sections;
Expand All @@ -164,12 +169,6 @@ class SpecialCaseList {
/// Parses just-constructed SpecialCaseList entries from a memory buffer.
LLVM_ABI bool parse(unsigned FileIdx, const MemoryBuffer *MB,
std::string &Error);

// Helper method for derived classes to search by Prefix, Query, and Category
// once they have already resolved a section entry.
LLVM_ABI unsigned inSectionBlame(const SectionEntries &Entries,
StringRef Prefix, StringRef Query,
StringRef Category) const;
};

} // namespace llvm
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Support/SpecialCaseList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,17 @@ SpecialCaseList::inSectionBlame(StringRef Section, StringRef Prefix,
StringRef Query, StringRef Category) const {
for (const auto &S : reverse(Sections)) {
if (S.SectionMatcher.match(Section)) {
unsigned Blame = inSectionBlame(S.Entries, Prefix, Query, Category);
unsigned Blame = S.getLastMatch(Prefix, Query, Category);
if (Blame)
return {S.FileIdx, Blame};
}
}
return NotFound;
}

unsigned SpecialCaseList::inSectionBlame(const SectionEntries &Entries,
StringRef Prefix, StringRef Query,
StringRef Category) const {
unsigned SpecialCaseList::Section::getLastMatch(StringRef Prefix,
StringRef Query,
StringRef Category) const {
SectionEntries::const_iterator I = Entries.find(Prefix);
if (I == Entries.end())
return 0;
Expand Down
Loading