summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/OptionArgParser.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/OptionArgParser.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/OptionArgParser.cpp')
-rw-r--r--lldb/source/Interpreter/OptionArgParser.cpp36
1 files changed, 14 insertions, 22 deletions
diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp
index efaac0720fd..14b81cd7b3d 100644
--- a/lldb/source/Interpreter/OptionArgParser.cpp
+++ b/lldb/source/Interpreter/OptionArgParser.cpp
@@ -211,29 +211,21 @@ lldb::addr_t OptionArgParser::ToAddress(const ExecutionContext *exe_ctx,
// pointer types.
static RegularExpression g_symbol_plus_offset_regex(
"^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$");
- RegularExpression::Match regex_match(3);
- if (g_symbol_plus_offset_regex.Execute(sref, &regex_match)) {
+
+ llvm::SmallVector<llvm::StringRef, 4> matches;
+ if (g_symbol_plus_offset_regex.Execute(sref, &matches)) {
uint64_t offset = 0;
- bool add = true;
- std::string name;
- std::string str;
- if (regex_match.GetMatchAtIndex(s, 1, name)) {
- if (regex_match.GetMatchAtIndex(s, 2, str)) {
- add = str[0] == '+';
-
- if (regex_match.GetMatchAtIndex(s, 3, str)) {
- if (!llvm::StringRef(str).getAsInteger(0, offset)) {
- Status error;
- addr = ToAddress(exe_ctx, name.c_str(), LLDB_INVALID_ADDRESS,
- &error);
- if (addr != LLDB_INVALID_ADDRESS) {
- if (add)
- return addr + offset;
- else
- return addr - offset;
- }
- }
- }
+ std::string name = matches[1].str();
+ std::string sign = matches[2].str();
+ std::string str_offset = matches[3].str();
+ if (!llvm::StringRef(str_offset).getAsInteger(0, offset)) {
+ Status error;
+ addr = ToAddress(exe_ctx, name.c_str(), LLDB_INVALID_ADDRESS, &error);
+ if (addr != LLDB_INVALID_ADDRESS) {
+ if (sign[0] == '+')
+ return addr + offset;
+ else
+ return addr - offset;
}
}
}
OpenPOWER on IntegriCloud