summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-08-16 21:25:36 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-08-16 21:25:36 +0000
commit3af3f1e8e253d93cb655388af69f4ed1722b4f51 (patch)
tree44b9e8ecf404119a1a81b54e27ea6559a5f5dd9a /lldb/source/Interpreter/CommandObjectRegexCommand.cpp
parent250aafa2c4a1bc2395edfe8d4365545bbe56fffe (diff)
downloadbcm5719-llvm-3af3f1e8e253d93cb655388af69f4ed1722b4f51.tar.gz
bcm5719-llvm-3af3f1e8e253d93cb655388af69f4ed1722b4f51.zip
[Utility] Reimplement RegularExpression on top of llvm::Regex
Originally I wanted to remove the RegularExpression class in Utility and replace it with llvm::Regex. However, during that transition I noticed that there are several places where need the regular expression string. So instead I propose to keep the RegularExpression class and make it a thin wrapper around llvm::Regex. This patch also removes the workaround for empty regular expressions. The result is that we are now (more or less) POSIX conformant. Differential revision: https://reviews.llvm.org/D66174 llvm-svn: 369153
Diffstat (limited to 'lldb/source/Interpreter/CommandObjectRegexCommand.cpp')
-rw-r--r--lldb/source/Interpreter/CommandObjectRegexCommand.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
index 19335b95ca3..16e6feb957c 100644
--- a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
+++ b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
@@ -30,15 +30,14 @@ bool CommandObjectRegexCommand::DoExecute(llvm::StringRef command,
CommandReturnObject &result) {
EntryCollection::const_iterator pos, end = m_entries.end();
for (pos = m_entries.begin(); pos != end; ++pos) {
- RegularExpression::Match regex_match(m_max_matches);
-
- if (pos->regex.Execute(command, &regex_match)) {
+ llvm::SmallVector<llvm::StringRef, 4> matches;
+ if (pos->regex.Execute(command, &matches)) {
std::string new_command(pos->command);
- std::string match_str;
char percent_var[8];
size_t idx, percent_var_idx;
for (uint32_t match_idx = 1; match_idx <= m_max_matches; ++match_idx) {
- if (regex_match.GetMatchAtIndex(command, match_idx, match_str)) {
+ if (match_idx < matches.size()) {
+ const std::string match_str = matches[match_idx].str();
const int percent_var_len =
::snprintf(percent_var, sizeof(percent_var), "%%%u", match_idx);
for (idx = 0; (percent_var_idx = new_command.find(
OpenPOWER on IntegriCloud