diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:17:04 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:17:04 +0000 |
commit | b915e9e0fc85ba6f398b3fab0db6a81a8913af94 (patch) | |
tree | 98b8f811c7aff2547cab8642daf372d6c59502fb /lib/Support/Regex.cpp | |
parent | 6421cca32f69ac849537a3cff78c352195e99f1b (diff) |
Notes
Diffstat (limited to 'lib/Support/Regex.cpp')
-rw-r--r-- | lib/Support/Regex.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Support/Regex.cpp b/lib/Support/Regex.cpp index e8344ef74d9c..68ba79e11766 100644 --- a/lib/Support/Regex.cpp +++ b/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. |