Skip to content

Commit 662b046

Browse files
committed
[NFC][Support] Remove unused getLongestMatch from SpecialCaseList
This method is not used anywhere. Remove it. Pull Request: llvm#167193
1 parent b95fdff commit 662b046

File tree

2 files changed

+19
-45
lines changed

2 files changed

+19
-45
lines changed

llvm/include/llvm/Support/SpecialCaseList.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ class SpecialCaseList {
110110
// classes.
111111
LLVM_ABI bool createInternal(const std::vector<std::string> &Paths,
112112
vfs::FileSystem &VFS, std::string &Error);
113-
LLVM_ABI bool createInternal(const MemoryBuffer *MB, std::string &Error,
114-
bool OrderBySize = false);
113+
LLVM_ABI bool createInternal(const MemoryBuffer *MB, std::string &Error);
115114

116115
SpecialCaseList() = default;
117116
SpecialCaseList(SpecialCaseList const &) = delete;
@@ -137,11 +136,6 @@ class SpecialCaseList {
137136
LLVM_ABI unsigned getLastMatch(StringRef Prefix, StringRef Query,
138137
StringRef Category) const;
139138

140-
// Helper method to search by Prefix, Query, and Category. Returns
141-
// matching rule, or empty string if there is no match.
142-
LLVM_ABI StringRef getLongestMatch(StringRef Prefix, StringRef Query,
143-
StringRef Category) const;
144-
145139
/// Returns true if the section has any entries for the given prefix.
146140
LLVM_ABI bool hasPrefix(StringRef Prefix) const;
147141

@@ -166,7 +160,7 @@ class SpecialCaseList {
166160

167161
/// Parses just-constructed SpecialCaseList entries from a memory buffer.
168162
LLVM_ABI bool parse(unsigned FileIdx, const MemoryBuffer *MB,
169-
std::string &Error, bool OrderBySize);
163+
std::string &Error);
170164
};
171165

172166
} // namespace llvm

llvm/lib/Support/SpecialCaseList.cpp

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static constexpr Match NotMatched = {"", 0};
4545
class RegexMatcher {
4646
public:
4747
Error insert(StringRef Pattern, unsigned LineNumber);
48-
void preprocess(bool BySize);
48+
void preprocess();
4949

5050
Match match(StringRef Query) const;
5151

@@ -63,7 +63,7 @@ class RegexMatcher {
6363
class GlobMatcher {
6464
public:
6565
Error insert(StringRef Pattern, unsigned LineNumber);
66-
void preprocess(bool BySize);
66+
void preprocess();
6767

6868
Match match(StringRef Query) const;
6969

@@ -92,7 +92,7 @@ class Matcher {
9292
Matcher(bool UseGlobs, bool RemoveDotSlash);
9393

9494
Error insert(StringRef Pattern, unsigned LineNumber);
95-
void preprocess(bool BySize);
95+
void preprocess();
9696
Match match(StringRef Query) const;
9797

9898
bool matchAny(StringRef Query) const { return match(Query).second > 0; }
@@ -125,13 +125,7 @@ Error RegexMatcher::insert(StringRef Pattern, unsigned LineNumber) {
125125
return Error::success();
126126
}
127127

128-
void RegexMatcher::preprocess(bool BySize) {
129-
if (BySize) {
130-
llvm::stable_sort(RegExes, [](const Reg &A, const Reg &B) {
131-
return A.Name.size() < B.Name.size();
132-
});
133-
}
134-
}
128+
void RegexMatcher::preprocess() {}
135129

136130
Match RegexMatcher::match(StringRef Query) const {
137131
for (const auto &R : reverse(RegExes))
@@ -151,13 +145,7 @@ Error GlobMatcher::insert(StringRef Pattern, unsigned LineNumber) {
151145
return Error::success();
152146
}
153147

154-
void GlobMatcher::preprocess(bool BySize) {
155-
if (BySize) {
156-
llvm::stable_sort(Globs, [](const Glob &A, const Glob &B) {
157-
return A.Name.size() < B.Name.size();
158-
});
159-
}
160-
148+
void GlobMatcher::preprocess() {
161149
for (const auto &[Idx, G] : enumerate(Globs)) {
162150
StringRef Prefix = G.Pattern.prefix();
163151
StringRef Suffix = G.Pattern.suffix();
@@ -241,8 +229,8 @@ Error Matcher::insert(StringRef Pattern, unsigned LineNumber) {
241229
return std::visit([&](auto &V) { return V.insert(Pattern, LineNumber); }, M);
242230
}
243231

244-
void Matcher::preprocess(bool BySize) {
245-
return std::visit([&](auto &V) { return V.preprocess(BySize); }, M);
232+
void Matcher::preprocess() {
233+
return std::visit([&](auto &V) { return V.preprocess(); }, M);
246234
}
247235

248236
Match Matcher::match(StringRef Query) const {
@@ -254,7 +242,7 @@ Match Matcher::match(StringRef Query) const {
254242

255243
class SpecialCaseList::Section::SectionImpl {
256244
friend class SpecialCaseList;
257-
void preprocess(bool OrderBySize);
245+
void preprocess();
258246
const Matcher *findMatcher(StringRef Prefix, StringRef Category) const;
259247

260248
public:
@@ -315,17 +303,17 @@ bool SpecialCaseList::createInternal(const std::vector<std::string> &Paths,
315303
return false;
316304
}
317305
std::string ParseError;
318-
if (!parse(i, FileOrErr.get().get(), ParseError, /*OrderBySize=*/false)) {
306+
if (!parse(i, FileOrErr.get().get(), ParseError)) {
319307
Error = (Twine("error parsing file '") + Path + "': " + ParseError).str();
320308
return false;
321309
}
322310
}
323311
return true;
324312
}
325313

326-
bool SpecialCaseList::createInternal(const MemoryBuffer *MB, std::string &Error,
327-
bool OrderBySize) {
328-
if (!parse(0, MB, Error, OrderBySize))
314+
bool SpecialCaseList::createInternal(const MemoryBuffer *MB,
315+
std::string &Error) {
316+
if (!parse(0, MB, Error))
329317
return false;
330318
return true;
331319
}
@@ -352,7 +340,7 @@ SpecialCaseList::addSection(StringRef SectionStr, unsigned FileNo,
352340
}
353341

354342
bool SpecialCaseList::parse(unsigned FileIdx, const MemoryBuffer *MB,
355-
std::string &Error, bool OrderBySize) {
343+
std::string &Error) {
356344
unsigned long long Version = 2;
357345

358346
StringRef Header = MB->getBuffer();
@@ -428,7 +416,7 @@ bool SpecialCaseList::parse(unsigned FileIdx, const MemoryBuffer *MB,
428416
}
429417

430418
for (Section &S : Sections)
431-
S.Impl->preprocess(OrderBySize);
419+
S.Impl->preprocess();
432420

433421
return true;
434422
}
@@ -479,11 +467,11 @@ SpecialCaseList::Section::SectionImpl::findMatcher(StringRef Prefix,
479467
return &II->second;
480468
}
481469

482-
void SpecialCaseList::Section::SectionImpl::preprocess(bool OrderBySize) {
483-
SectionMatcher.preprocess(false);
470+
void SpecialCaseList::Section::SectionImpl::preprocess() {
471+
SectionMatcher.preprocess();
484472
for (auto &[K1, E] : Entries)
485473
for (auto &[K2, M] : E)
486-
M.preprocess(OrderBySize);
474+
M.preprocess();
487475
}
488476

489477
unsigned SpecialCaseList::Section::getLastMatch(StringRef Prefix,
@@ -494,14 +482,6 @@ unsigned SpecialCaseList::Section::getLastMatch(StringRef Prefix,
494482
return 0;
495483
}
496484

497-
StringRef SpecialCaseList::Section::getLongestMatch(StringRef Prefix,
498-
StringRef Query,
499-
StringRef Category) const {
500-
if (const Matcher *M = Impl->findMatcher(Prefix, Category))
501-
return M->match(Query).first;
502-
return {};
503-
}
504-
505485
bool SpecialCaseList::Section::hasPrefix(StringRef Prefix) const {
506486
return Impl->Entries.find(Prefix) != Impl->Entries.end();
507487
}

0 commit comments

Comments
 (0)