summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility/RegularExpression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Utility/RegularExpression.cpp')
-rw-r--r--lldb/source/Utility/RegularExpression.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/lldb/source/Utility/RegularExpression.cpp b/lldb/source/Utility/RegularExpression.cpp
index 356d78a041f..432b45ee4c4 100644
--- a/lldb/source/Utility/RegularExpression.cpp
+++ b/lldb/source/Utility/RegularExpression.cpp
@@ -12,22 +12,19 @@
using namespace lldb_private;
-RegularExpression::RegularExpression(llvm::StringRef str) { Compile(str); }
+RegularExpression::RegularExpression(llvm::StringRef str)
+ : m_regex_text(str),
+ // m_regex does not reference str anymore after it is constructed.
+ m_regex(llvm::Regex(str)) {}
RegularExpression::RegularExpression(const RegularExpression &rhs)
- : RegularExpression() {
- Compile(rhs.GetText());
-}
-
-bool RegularExpression::Compile(llvm::StringRef str) {
- m_regex_text = str;
- m_regex = llvm::Regex(str);
- return IsValid();
-}
+ : RegularExpression(rhs.GetText()) {}
bool RegularExpression::Execute(
llvm::StringRef str,
llvm::SmallVectorImpl<llvm::StringRef> *matches) const {
+ if (!IsValid())
+ return false;
return m_regex.match(str, matches);
}
OpenPOWER on IntegriCloud