summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/Regex.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Support/Regex.cpp b/llvm/lib/Support/Regex.cpp
index 35641f3b7cb..68ba79e1176 100644
--- a/llvm/lib/Support/Regex.cpp
+++ b/llvm/lib/Support/Regex.cpp
@@ -34,6 +34,13 @@ Regex::Regex(StringRef regex, unsigned Flags) {
error = llvm_regcomp(preg, regex.data(), flags|REG_PEND);
}
+Regex::Regex(Regex &&regex) {
+ preg = regex.preg;
+ error = regex.error;
+ regex.preg = nullptr;
+ regex.error = REG_BADPAT;
+}
+
Regex::~Regex() {
if (preg) {
llvm_regfree(preg);
@@ -59,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.
OpenPOWER on IntegriCloud