diff options
author | Greg Clayton <gclayton@apple.com> | 2013-04-03 21:37:16 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2013-04-03 21:37:16 +0000 |
commit | bc43cab51d8ceaebb0b56605f6b609ec3c0055e8 (patch) | |
tree | 5ba947cb76729bbbdb8f4bd31ce63500a41ddf3e /lldb/source/Core/Disassembler.cpp | |
parent | d3254b446211d3f1a455c4f2247dc910df68d69f (diff) | |
download | bcm5719-llvm-bc43cab51d8ceaebb0b56605f6b609ec3c0055e8.tar.gz bcm5719-llvm-bc43cab51d8ceaebb0b56605f6b609ec3c0055e8.zip |
<rdar://problem/13384801>
Make lldb_private::RegularExpression thread safe everywhere. This was done by removing the m_matches array from the lldb_private::RegularExpression class and putting it into the new lldb_private::RegularExpression::Match class. When executing a regular expression you now have the option to create a lldb_private::RegularExpression::Match object and pass a pointer in if you want to get parenthesized matching. If you don't want any matching, you pass in NULL. The lldb_private::RegularExpression::Match object is initialized with the number of matches you desire. Any matching strings are now extracted from the lldb_private::RegularExpression::Match objects. This makes the regular expression objects thread safe and as a result many more regex objects were turned into static objects that end up using a local lldb_private::RegularExpression::Match object when executing.
llvm-svn: 178702
Diffstat (limited to 'lldb/source/Core/Disassembler.cpp')
-rw-r--r-- | lldb/source/Core/Disassembler.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index 3d4b7ffd19b..2a67f1db165 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -684,10 +684,11 @@ Instruction::ReadArray (FILE *in_file, Stream *out_stream, OptionValue::Type dat if (line.size() > 0) { std::string value; - RegularExpression reg_exp ("^[ \t]*([^ \t]+)[ \t]*$"); - bool reg_exp_success = reg_exp.Execute (line.c_str(), 1); + static RegularExpression g_reg_exp ("^[ \t]*([^ \t]+)[ \t]*$"); + RegularExpression::Match regex_match(1); + bool reg_exp_success = g_reg_exp.Execute (line.c_str(), ®ex_match); if (reg_exp_success) - reg_exp.GetMatchAtIndex (line.c_str(), 1, value); + regex_match.GetMatchAtIndex (line.c_str(), 1, value); else value = line; @@ -752,14 +753,16 @@ Instruction::ReadDictionary (FILE *in_file, Stream *out_stream) // Try to find a key-value pair in the current line and add it to the dictionary. if (line.size() > 0) { - RegularExpression reg_exp ("^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$"); - bool reg_exp_success = reg_exp.Execute (line.c_str(), 2); + static RegularExpression g_reg_exp ("^[ \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.c_str(), ®ex_match); std::string key; std::string value; if (reg_exp_success) { - reg_exp.GetMatchAtIndex (line.c_str(), 1, key); - reg_exp.GetMatchAtIndex (line.c_str(), 2, value); + regex_match.GetMatchAtIndex (line.c_str(), 1, key); + regex_match.GetMatchAtIndex (line.c_str(), 2, value); } else { |