Go to the documentation of this file.
66 Error.resize(len - 1);
76 RegexErrorToString(error, preg,
Error);
87 std::string *
Error)
const {
96 unsigned nmatch = Matches ? preg->
re_nsub+1 : 0;
100 pm.resize(nmatch > 0 ? nmatch : 1);
102 pm[0].rm_eo = String.size();
112 RegexErrorToString(error, preg, *
Error);
121 for (
unsigned i = 0;
i != nmatch; ++
i) {
122 if (
pm[
i].rm_so == -1) {
129 pm[
i].rm_eo-
pm[
i].rm_so));
137 std::string *
Error)
const {
142 return std::string(String);
146 std::string Res(String.begin(), Matches[0].begin());
149 while (!Repl.
empty()) {
151 std::pair<StringRef, StringRef> Split = Repl.
split(
'\\');
157 if (Split.second.empty()) {
158 if (Repl.
size() != Split.first.size() &&
160 *
Error =
"replacement string contained trailing backslash";
186 case '0':
case '1':
case '2':
case '3':
case '4':
187 case '5':
case '6':
case '7':
case '8':
case '9': {
193 if (!
Ref.getAsInteger(10, RefValue) &&
194 RefValue < Matches.size())
195 Res += Matches[RefValue];
197 *
Error = (
"invalid backreference string '" +
Twine(
Ref) +
"'").str();
204 Res +=
StringRef(Matches[0].
end(), String.end() - Matches[0].end());
220 std::string RegexStr;
221 for (
char C : String) {
This is an optimization pass for GlobalISel generic memory operations.
static constexpr size_t npos
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
int llvm_regexec(const llvm_regex_t *, const char *, size_t, llvm_regmatch_t[], int)
const_iterator end(StringRef path)
Get end iterator over path.
int llvm_regcomp(llvm_regex_t *preg, const char *pattern, int cflags)
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
size_t llvm_regerror(int errcode, const llvm_regex_t *preg, char *errbuf, size_t errbuf_size)
@ Ref
The access may reference the value stored in memory.
(vector float) vec_cmpeq(*A, *B) C
unsigned getNumMatches() const
getNumMatches - In a valid regex, return the number of parenthesized matches it contains.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
static const char RegexMetachars[]
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr bool empty() const
empty - Check if the string is empty.
@ BasicRegex
By default, the POSIX extended regular expression (ERE) syntax is assumed.
void llvm_regfree(llvm_regex_t *)
static bool isLiteralERE(StringRef Str)
If this function returns true, ^Str$ is an extended regular expression that matches Str and only Str.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::string sub(StringRef Repl, StringRef String, std::string *Error=nullptr) const
sub - Return the result of replacing the first match of the regex in String with the Repl string.
size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
StringRef - Represent a constant reference to a string, i.e.
@ IgnoreCase
Compile for matching that ignores upper/lower case distinctions.
static void pm(uint64_t &Value)
Adjusts a program memory address.
@ Newline
Compile for newline-sensitive matching.
constexpr size_t size() const
size - Get the string size.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Lightweight error class with error context and mandatory checking.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
static std::string escape(StringRef String)
Turn String into a regex by escaping its special characters.