Introduce Regex::isLiteralERE function.

This will be used to implement an optimisation for literal entries
in special case lists.

Differential Revision: http://llvm-reviews.chandlerc.com/D1278

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187731 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne
2013-08-05 17:47:59 +00:00
parent 2a37c7e9e6
commit aa80e61b0d
3 changed files with 26 additions and 0 deletions

View File

@ -168,3 +168,10 @@ std::string Regex::sub(StringRef Repl, StringRef String,
return Res;
}
bool Regex::isLiteralERE(StringRef Str) {
// Check for regex metacharacters. This list was derived from our regex
// implementation in regcomp.c and double checked against the POSIX extended
// regular expression specification.
return Str.find_first_of("()^$|*+?.[]\\{}") == StringRef::npos;
}