62 Error.resize(len - 1);
77 unsigned nmatch = Matches ? preg->
re_nsub+1 : 0;
81 pm.
resize(nmatch > 0 ? nmatch : 1);
83 pm[0].rm_eo = String.
size();
100 for (
unsigned i = 0; i != nmatch; ++i) {
101 if (pm[i].rm_so == -1) {
106 assert(pm[i].rm_eo >= pm[i].rm_so);
108 pm[i].rm_eo-pm[i].rm_so));
116 std::string *
Error) {
120 if (Error && !Error->empty()) *Error =
"";
123 if (!
match(String, &Matches))
128 std::string Res(String.
begin(), Matches[0].
begin());
131 while (!Repl.
empty()) {
133 std::pair<StringRef, StringRef>
Split = Repl.
split(
'\\');
139 if (Split.second.empty()) {
140 if (Repl.
size() != Split.first.size() &&
141 Error && Error->empty())
142 *Error =
"replacement string contained trailing backslash";
168 case '0':
case '1':
case '2':
case '3':
case '4':
169 case '5':
case '6':
case '7':
case '8':
case '9': {
176 RefValue < Matches.
size())
177 Res += Matches[RefValue];
178 else if (Error && Error->empty())
179 *Error = (
"invalid backreference string '" +
Twine(Ref) +
"'").str();
202 std::string RegexStr;
203 for (
unsigned i = 0, e = String.
size(); i != e; ++i) {
204 if (strchr(RegexMetachars, String[i]))
206 RegexStr += String[i];
const_iterator end(StringRef path)
Get end iterator over path.
This class represents lattice values for constants.
void push_back(const T &Elt)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
static std::string escape(StringRef String)
Turn String into a regex by escaping its special characters.
int llvm_regcomp(llvm_regex_t *preg, const char *pattern, int cflags)
void llvm_regfree(llvm_regex_t *)
Compile for newline-sensitive matching.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Compile for matching that ignores upper/lower case distinctions.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The access may reference the value stored in memory.
size_t llvm_regerror(int errcode, const llvm_regex_t *preg, char *errbuf, size_t errbuf_size)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
LLVM_NODISCARD 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.
static const char RegexMetachars[]
By default, the POSIX extended regular expression (ERE) syntax is assumed.
static bool isLiteralERE(StringRef Str)
If this function returns true, ^Str$ is an extended regular expression that matches Str and only Str...
void pm(uint64_t &Value)
Adjusts a program memory address.
std::string sub(StringRef Repl, StringRef String, std::string *Error=nullptr)
sub - Return the result of replacing the first match of the regex in String with the Repl string...
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
bool isValid(std::string &Error) const
isValid - returns the error encountered during regex compilation, or matching, if any...
unsigned getNumMatches() const
getNumMatches - In a valid regex, return the number of parenthesized matches it contains.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
pointer data()
Return a pointer to the vector's buffer, even if empty().
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
int llvm_regexec(const llvm_regex_t *, const char *, size_t, llvm_regmatch_t [], int)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr)
matches - Match the regex against a given String.
StringRef - Represent a constant reference to a string, i.e.
static void Split(std::vector< std::string > &V, StringRef S)
Splits a string of comma separated items in to a vector of strings.