diff options
Diffstat (limited to 'llvm/lib/Support/Regex.cpp')
-rw-r--r-- | llvm/lib/Support/Regex.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Support/Regex.cpp b/llvm/lib/Support/Regex.cpp index 8da345d4f1404..0d5cc1c00db11 100644 --- a/llvm/lib/Support/Regex.cpp +++ b/llvm/lib/Support/Regex.cpp @@ -14,6 +14,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" +#include <cassert> #include <string> // Important this comes last because it defines "_REGEX_H_". At least on @@ -25,7 +26,7 @@ using namespace llvm; Regex::Regex() : preg(nullptr), error(REG_BADPAT) {} -Regex::Regex(StringRef regex, unsigned Flags) { +Regex::Regex(StringRef regex, RegexFlags Flags) { unsigned flags = 0; preg = new llvm_regex(); preg->re_endp = regex.end(); @@ -38,6 +39,9 @@ Regex::Regex(StringRef regex, unsigned Flags) { error = llvm_regcomp(preg, regex.data(), flags|REG_PEND); } +Regex::Regex(StringRef regex, unsigned Flags) + : Regex(regex, static_cast<RegexFlags>(Flags)) {} + Regex::Regex(Regex &®ex) { preg = regex.preg; error = regex.error; @@ -135,7 +139,7 @@ std::string Regex::sub(StringRef Repl, StringRef String, // Return the input if there was no match. if (!match(String, &Matches, Error)) - return String; + return std::string(String); // Otherwise splice in the replacement string, starting with the prefix before // the match. |