[Lldb-commits] [PATCH] D132307: [lldb] Switch RegularExpression from llvm::Regex to std::regex

Dave Lee via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Aug 20 11:24:03 PDT 2022


kastiglione added inline comments.


================
Comment at: lldb/source/Utility/CMakeLists.txt:29
+  PROPERTIES COMPILE_OPTIONS
+  "-fcxx-exceptions"
+)
----------------
the `std::regex` constructor throws `std::regex_error` if the pattern is invalid. For this reason, exceptions are enabled for this one file.


================
Comment at: lldb/source/Utility/RegularExpression.cpp:51
+bool RegularExpression::IsValid() const {
+  return !m_regex_text.empty() && !m_regex_error;
+}
----------------
`llvm::Regex` considers the empty string to be an invalid pattern, while `std::regex` does not.


================
Comment at: lldb/source/Utility/RegularExpression.cpp:58
+  if (!IsValid()) {
+    std::string error = m_regex_error ? m_regex_error->what() : "empty regex";
     return llvm::make_error<llvm::StringError>(error,
----------------
`llvm::Regex` considers the empty string to be an invalid pattern, while `std::regex` does not.


================
Comment at: lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py:11-21
+                    substrs=["error: Function name regular expression could "
+                             "not be compiled: The expression contained mismatched ( and )."])
 
         # Point out if looks like the user provided a globbing expression.
         self.expect("breakpoint set --func-regex *a", error=True,
-                    substrs=["error: Function name regular expression could " +
-                             "not be compiled: repetition-operator operand invalid",
+                    substrs=["error: Function name regular expression could "
+                             "not be compiled: One of *?+{ was not preceded by a valid regular expression.",
----------------
the error messages have changed.


================
Comment at: lldb/test/API/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py:37
 
-        source_regex = "Set . breakpoint here"
+        source_regex = r"Set \w\d? breakpoint here"
         main_break = target.BreakpointCreateBySourceRegex(
----------------
exercise the features that aren't supported by `llvm::Regex`


================
Comment at: lldb/test/API/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py:69
         target_files.Append(lldb.SBFileSpec("main.c"))
-        source_regex = "Set . breakpoint here"
+        source_regex = r"Set \w\d? breakpoint here"
         main_break = target.BreakpointCreateBySourceRegex(
----------------
exercise the features that aren't supported by `llvm::Regex`


================
Comment at: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py:132
         (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint(
-            self, "Stop here to check by ref and ptr.",
+            self, "Stop here to check by ref and ptr",
             lldb.SBFileSpec("main.cpp", False))
----------------
previously, there was a `.`, which `llvm::Regex` matched to a newline, while `std::regex` does not, resulting in no match.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132307/new/

https://reviews.llvm.org/D132307



More information about the lldb-commits mailing list