10#include "llvm/ADT/STLExtras.h"
11#include "llvm/ADT/SmallString.h"
27 StringRef Glob = UntrimmedGlob.trim();
33 SmallString<128> RegexText(
"^");
34 StringRef MetaChars(
"()^$|*+?.[]\\{}");
37 RegexText.push_back(
'.');
38 else if (MetaChars.contains(
C))
39 RegexText.push_back(
'\\');
40 RegexText.push_back(
C);
42 RegexText.push_back(
'$');
43 return {RegexText.str()};
47 Items.reserve(Globs.count(
',') + Globs.count(
'\n') + 1);
53 if (Item.IsPositive || KeepNegativeGlobs)
54 Items.push_back(std::move(Item));
55 }
while (!Globs.empty());
61 for (
const GlobListItem &Item : llvm::reverse(Items)) {
62 if (Item.Regex.match(S))
63 return Item.IsPositive;
69 auto Entry = Cache.try_emplace(S);
70 bool &Value =
Entry.first->getValue();
bool contains(StringRef S) const override
Read-only set of strings represented as a list of positive and negative globs.
GlobList(StringRef Globs, bool KeepNegativeGlobs=true)
Globs is a comma-separated list of globs (only the '*' metacharacter is supported) with an optional '...
virtual bool contains(StringRef S) const
Returns true if the pattern matches S.
static llvm::StringRef extractNextGlob(StringRef &GlobList)
static bool consumeNegativeIndicator(StringRef &GlobList)
static llvm::Regex createRegexFromGlob(StringRef &Glob)