10#include "llvm/ADT/STLExtras.h"
11#include "llvm/ADT/SmallString.h"
30 StringRef Glob = UntrimmedGlob.trim();
32 SmallString<128> RegexText(
"^");
33 StringRef MetaChars(
"()^$|*+?.[]\\{}");
36 RegexText.push_back(
'.');
37 else if (MetaChars.contains(
C))
38 RegexText.push_back(
'\\');
39 RegexText.push_back(
C);
41 RegexText.push_back(
'$');
42 return {RegexText.str()};
46 Items.reserve(Globs.count(
',') + Globs.count(
'\n') + 1);
51 if (Item.IsPositive || KeepNegativeGlobs)
52 Items.push_back(std::move(Item));
53 }
while (!Globs.empty());
59 for (
const GlobListItem &Item : llvm::reverse(Items)) {
60 if (Item.Regex.match(S))
61 return Item.IsPositive;
67 auto Entry = Cache.try_emplace(S);
68 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::Regex consumeGlob(StringRef &GlobList)
static bool consumeNegativeIndicator(StringRef &GlobList)