[llvm-branch-commits] [NFC][SpecialCaseList] Rename SpecialCaseList::inSectionBlame and move into Section (PR #162390)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Oct 7 15:30:07 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/162390.diff
3 Files Affected:
- (modified) clang/lib/Basic/SanitizerSpecialCaseList.cpp (+1-2)
- (modified) llvm/include/llvm/Support/SpecialCaseList.h (+5-6)
- (modified) llvm/lib/Support/SpecialCaseList.cpp (+4-4)
``````````diff
diff --git a/clang/lib/Basic/SanitizerSpecialCaseList.cpp b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
index d8ccc50a8561e..a1dc4a7ec99bf 100644
--- a/clang/lib/Basic/SanitizerSpecialCaseList.cpp
+++ b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
@@ -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};
}
diff --git a/llvm/include/llvm/Support/SpecialCaseList.h b/llvm/include/llvm/Support/SpecialCaseList.h
index c2c9271b0a37a..55d3d12dc3d5f 100644
--- a/llvm/include/llvm/Support/SpecialCaseList.h
+++ b/llvm/include/llvm/Support/SpecialCaseList.h
@@ -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;
@@ -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
diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp
index 4b038850b62ca..a9b502ad64f1d 100644
--- a/llvm/lib/Support/SpecialCaseList.cpp
+++ b/llvm/lib/Support/SpecialCaseList.cpp
@@ -219,7 +219,7 @@ 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};
}
@@ -227,9 +227,9 @@ SpecialCaseList::inSectionBlame(StringRef Section, StringRef Prefix,
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/162390
More information about the llvm-branch-commits
mailing list