diff options
Diffstat (limited to 'contrib/llvm/lib/Support/Regex.cpp')
-rw-r--r-- | contrib/llvm/lib/Support/Regex.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/llvm/lib/Support/Regex.cpp b/contrib/llvm/lib/Support/Regex.cpp index e8344ef..68ba79e 100644 --- a/contrib/llvm/lib/Support/Regex.cpp +++ b/contrib/llvm/lib/Support/Regex.cpp @@ -19,6 +19,8 @@ #include <string> using namespace llvm; +Regex::Regex() : preg(nullptr), error(REG_BADPAT) {} + Regex::Regex(StringRef regex, unsigned Flags) { unsigned flags = 0; preg = new llvm_regex(); @@ -32,6 +34,13 @@ Regex::Regex(StringRef regex, unsigned Flags) { error = llvm_regcomp(preg, regex.data(), flags|REG_PEND); } +Regex::Regex(Regex &®ex) { + preg = regex.preg; + error = regex.error; + regex.preg = nullptr; + regex.error = REG_BADPAT; +} + Regex::~Regex() { if (preg) { llvm_regfree(preg); @@ -57,6 +66,9 @@ unsigned Regex::getNumMatches() const { } bool Regex::match(StringRef String, SmallVectorImpl<StringRef> *Matches){ + if (error) + return false; + unsigned nmatch = Matches ? preg->re_nsub+1 : 0; // pmatch needs to have at least one element. |