1212#ifndef LLVM_SUPPORT_SPECIALCASELIST_H
1313#define LLVM_SUPPORT_SPECIALCASELIST_H
1414
15- #include " llvm/ADT/ArrayRef.h"
16- #include " llvm/ADT/RadixTree.h"
17- #include " llvm/ADT/SmallVector.h"
18- #include " llvm/ADT/StringMap.h"
19- #include " llvm/ADT/iterator_range.h"
2015#include " llvm/Support/Allocator.h"
21- #include " llvm/Support/Compiler.h"
22- #include " llvm/Support/GlobPattern.h"
23- #include " llvm/Support/Regex.h"
16+ #include " llvm/Support/Error.h"
2417#include < memory>
2518#include < string>
2619#include < utility>
27- #include < variant>
2820#include < vector>
2921
3022namespace llvm {
@@ -125,83 +117,11 @@ class SpecialCaseList {
125117 SpecialCaseList (SpecialCaseList const &) = delete ;
126118 SpecialCaseList &operator =(SpecialCaseList const &) = delete ;
127119
128- private:
129- using Match = std::pair<StringRef, unsigned >;
130- static constexpr Match NotMatched = {" " , 0 };
131-
132- // Lagacy v1 matcher.
133- class RegexMatcher {
134- public:
135- LLVM_ABI Error insert (StringRef Pattern, unsigned LineNumber);
136- LLVM_ABI void preprocess (bool BySize);
137-
138- LLVM_ABI Match match (StringRef Query) const ;
139-
140- struct Reg {
141- Reg (StringRef Name, unsigned LineNo, Regex &&Rg)
142- : Name(Name), LineNo(LineNo), Rg(std::move(Rg)) {}
143- StringRef Name;
144- unsigned LineNo;
145- Regex Rg;
146- };
147-
148- std::vector<Reg> RegExes;
149- };
150-
151- class GlobMatcher {
152- public:
153- LLVM_ABI Error insert (StringRef Pattern, unsigned LineNumber);
154- LLVM_ABI void preprocess (bool BySize);
155-
156- LLVM_ABI Match match (StringRef Query) const ;
157-
158- struct Glob {
159- Glob (StringRef Name, unsigned LineNo, GlobPattern &&Pattern)
160- : Name(Name), LineNo(LineNo), Pattern(std::move(Pattern)) {}
161- StringRef Name;
162- unsigned LineNo;
163- GlobPattern Pattern;
164- };
165-
166- std::vector<GlobMatcher::Glob> Globs;
167-
168- RadixTree<iterator_range<StringRef::const_iterator>,
169- RadixTree<iterator_range<StringRef::const_reverse_iterator>,
170- SmallVector<int , 1 >>>
171- PrefixSuffixToGlob;
172-
173- RadixTree<iterator_range<StringRef::const_iterator>, SmallVector<int , 1 >>
174- SubstrToGlob;
175- };
176-
177- // / Represents a set of patterns and their line numbers
178- class Matcher {
179- public:
180- LLVM_ABI Matcher (bool UseGlobs, bool RemoveDotSlash);
181-
182- LLVM_ABI Error insert (StringRef Pattern, unsigned LineNumber);
183- LLVM_ABI void preprocess (bool BySize);
184-
185- LLVM_ABI Match match (StringRef Query) const ;
186-
187- LLVM_ABI bool matchAny (StringRef Query) const {
188- return match (Query) != NotMatched;
189- }
190-
191- std::variant<RegexMatcher, GlobMatcher> M;
192- bool RemoveDotSlash;
193- };
194-
195- using SectionEntries = StringMap<StringMap<Matcher>>;
196-
197- protected:
198120 class Section {
199121 public:
200- Section (StringRef Name, unsigned FileIdx, bool UseGlobs)
201- : SectionMatcher(UseGlobs, /* RemoveDotSlash=*/ false ), Name(Name),
202- FileIdx (FileIdx) {}
203-
204- Section (Section &&) = default;
122+ LLVM_ABI Section (StringRef Name, unsigned FileIdx, bool UseGlobs);
123+ LLVM_ABI Section (Section &&);
124+ LLVM_ABI ~Section ();
205125
206126 // Return name of the section, it's entire string in [].
207127 StringRef name () const { return Name; }
@@ -227,17 +147,14 @@ class SpecialCaseList {
227147
228148 private:
229149 friend class SpecialCaseList ;
230- LLVM_ABI void preprocess (bool OrderBySize);
231- LLVM_ABI const SpecialCaseList::Matcher *
232- findMatcher (StringRef Prefix, StringRef Category) const ;
150+ class SectionImpl ;
233151
234- Matcher SectionMatcher;
235152 StringRef Name;
236- SectionEntries Entries;
237153 unsigned FileIdx;
154+ std::unique_ptr<SectionImpl> Impl;
238155 };
239156
240- ArrayRef< const Section> sections () const { return Sections; }
157+ const std::vector< Section> & sections () const ;
241158
242159private:
243160 BumpPtrAllocator StrAlloc;
0 commit comments