diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-08-16 21:25:36 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-08-16 21:25:36 +0000 |
commit | 3af3f1e8e253d93cb655388af69f4ed1722b4f51 (patch) | |
tree | 44b9e8ecf404119a1a81b54e27ea6559a5f5dd9a /lldb/source/Core/Disassembler.cpp | |
parent | 250aafa2c4a1bc2395edfe8d4365545bbe56fffe (diff) | |
download | bcm5719-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/Core/Disassembler.cpp')
-rw-r--r-- | lldb/source/Core/Disassembler.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index af7cf82d470..f48f0be0682 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -355,12 +355,9 @@ bool Disassembler::ElideMixedSourceAndDisassemblyLine( const char *function_name = sc.GetFunctionName(Mangled::ePreferDemangledWithoutArguments) .GetCString(); - if (function_name) { - RegularExpression::Match regex_match(1); - if (avoid_regex->Execute(function_name, ®ex_match)) { - // skip this source line - return true; - } + if (function_name && avoid_regex->Execute(function_name)) { + // skip this source line + return true; } } // don't skip this source line @@ -793,10 +790,9 @@ OptionValueSP Instruction::ReadArray(FILE *in_file, Stream *out_stream, std::string value; static RegularExpression g_reg_exp( llvm::StringRef("^[ \t]*([^ \t]+)[ \t]*$")); - RegularExpression::Match regex_match(1); - bool reg_exp_success = g_reg_exp.Execute(line, ®ex_match); - if (reg_exp_success) - regex_match.GetMatchAtIndex(line.c_str(), 1, value); + llvm::SmallVector<llvm::StringRef, 2> matches; + if (g_reg_exp.Execute(line, &matches)) + value = matches[1].str(); else value = line; @@ -856,14 +852,15 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream *out_stream) { if (!line.empty()) { static RegularExpression g_reg_exp(llvm::StringRef( "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$")); - RegularExpression::Match regex_match(2); - bool reg_exp_success = g_reg_exp.Execute(line, ®ex_match); + llvm::SmallVector<llvm::StringRef, 3> matches; + + bool reg_exp_success = g_reg_exp.Execute(line, &matches); std::string key; std::string value; if (reg_exp_success) { - regex_match.GetMatchAtIndex(line.c_str(), 1, key); - regex_match.GetMatchAtIndex(line.c_str(), 2, value); + key = matches[1].str(); + value = matches[2].str(); } else { out_stream->Printf("Instruction::ReadDictionary: Failure executing " "regular expression.\n"); |