File tree 2 files changed +31
-20
lines changed
2 files changed +31
-20
lines changed Original file line number Diff line number Diff line change @@ -42,15 +42,20 @@ static llvm::Regex ConsumeGlob(StringRef &GlobList) {
42
42
return llvm::Regex (RegexText);
43
43
}
44
44
45
- GlobList::GlobList (StringRef Globs)
46
- : Positive(!ConsumeNegativeIndicator(Globs)), Regex(ConsumeGlob(Globs)),
47
- NextGlob(Globs.empty() ? nullptr : new GlobList(Globs)) {}
48
-
49
- bool GlobList::contains (StringRef S, bool Contains) {
50
- if (Regex.match (S))
51
- Contains = Positive;
45
+ GlobList::GlobList (StringRef Globs) {
46
+ do {
47
+ GlobListItem Item;
48
+ Item.IsPositive = !ConsumeNegativeIndicator (Globs);
49
+ Item.Regex = ConsumeGlob (Globs);
50
+ Items.push_back (std::move (Item));
51
+ } while (!Globs.empty ());
52
+ }
52
53
53
- if (NextGlob)
54
- Contains = NextGlob->contains (S, Contains);
54
+ bool GlobList::contains (StringRef S) {
55
+ bool Contains = false ;
56
+ for (const GlobListItem &Item : Items) {
57
+ if (Item.Regex .match (S))
58
+ Contains = Item.IsPositive ;
59
+ }
55
60
return Contains;
56
61
}
Original file line number Diff line number Diff line change 12
12
#include " clang/Basic/LLVM.h"
13
13
#include " llvm/ADT/StringRef.h"
14
14
#include " llvm/Support/Regex.h"
15
- #include < memory >
15
+ #include < vector >
16
16
17
17
namespace clang {
18
18
namespace tidy {
19
19
20
- // / Read-only set of strings represented as a list of positive and
21
- // / negative globs. Positive globs add all matched strings to the set, negative
22
- // / globs remove them in the order of appearance in the list.
20
+ // / Read-only set of strings represented as a list of positive and negative
21
+ // / globs.
22
+ // /
23
+ // / Positive globs add all matched strings to the set, negative globs remove
24
+ // / them in the order of appearance in the list.
23
25
class GlobList {
24
26
public:
25
- // / \p GlobList is a comma-separated list of globs (only '*'
26
- // / metacharacter is supported) with optional '-' prefix to denote exclusion.
27
+ // / \p Globs is a comma-separated list of globs (only the '*' metacharacter is
28
+ // / supported) with an optional '-' prefix to denote exclusion.
29
+ // /
30
+ // / An empty \p Globs string is interpreted as one glob that matches an empty
31
+ // / string.
27
32
GlobList (StringRef Globs);
28
33
29
34
// / Returns \c true if the pattern matches \p S. The result is the last
30
35
// / matching glob's Positive flag.
31
- bool contains (StringRef S) { return contains (S, false ); }
36
+ bool contains (StringRef S);
32
37
33
38
private:
34
- bool contains (StringRef S, bool Contains);
35
39
36
- bool Positive;
37
- llvm::Regex Regex;
38
- std::unique_ptr<GlobList> NextGlob;
40
+ struct GlobListItem {
41
+ bool IsPositive;
42
+ mutable llvm::Regex Regex;
43
+ };
44
+ std::vector<GlobListItem> Items;
39
45
};
40
46
41
47
} // end namespace tidy
You can’t perform that action at this time.
0 commit comments