From b9c1b51e45b845debb76d8658edabca70ca56079 Mon Sep 17 00:00:00 2001 From: Kate Stone Date: Tue, 6 Sep 2016 20:57:50 +0000 Subject: =?UTF-8?q?***=20This=20commit=20represents=20a=20complete=20refor?= =?UTF-8?q?matting=20of=20the=20LLDB=20source=20code=20***=20to=20conform?= =?UTF-8?q?=20to=20clang-format=E2=80=99s=20LLVM=20style.=20=20This=20kind?= =?UTF-8?q?=20of=20mass=20change=20has=20***=20two=20obvious=20implication?= =?UTF-8?q?s:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751 --- .../Interpreter/CommandObjectRegexCommand.cpp | 190 +++++++++------------ 1 file changed, 80 insertions(+), 110 deletions(-) (limited to 'lldb/source/Interpreter/CommandObjectRegexCommand.cpp') diff --git a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp index 12de6d0..53e14c4 100644 --- a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp +++ b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp @@ -22,129 +22,99 @@ using namespace lldb_private; //---------------------------------------------------------------------- // CommandObjectRegexCommand constructor //---------------------------------------------------------------------- -CommandObjectRegexCommand::CommandObjectRegexCommand -( - CommandInterpreter &interpreter, - const char *name, - const char *help, - const char *syntax, - uint32_t max_matches, - uint32_t completion_type_mask, - bool is_removable -) : - CommandObjectRaw (interpreter, name, help, syntax), - m_max_matches (max_matches), - m_completion_type_mask (completion_type_mask), - m_entries (), - m_is_removable (is_removable) -{ -} +CommandObjectRegexCommand::CommandObjectRegexCommand( + CommandInterpreter &interpreter, const char *name, const char *help, + const char *syntax, uint32_t max_matches, uint32_t completion_type_mask, + bool is_removable) + : CommandObjectRaw(interpreter, name, help, syntax), + m_max_matches(max_matches), m_completion_type_mask(completion_type_mask), + m_entries(), m_is_removable(is_removable) {} //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -CommandObjectRegexCommand::~CommandObjectRegexCommand() -{ -} - +CommandObjectRegexCommand::~CommandObjectRegexCommand() {} -bool -CommandObjectRegexCommand::DoExecute -( - const char *command, - CommandReturnObject &result -) -{ - if (command) - { - EntryCollection::const_iterator pos, end = m_entries.end(); - for (pos = m_entries.begin(); pos != end; ++pos) - { - RegularExpression::Match regex_match(m_max_matches); +bool CommandObjectRegexCommand::DoExecute(const char *command, + CommandReturnObject &result) { + if (command) { + 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, ®ex_match)) - { - 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)) - { - const int percent_var_len = ::snprintf (percent_var, sizeof(percent_var), "%%%u", match_idx); - for (idx = 0; (percent_var_idx = new_command.find(percent_var, idx)) != std::string::npos; ) - { - new_command.erase(percent_var_idx, percent_var_len); - new_command.insert(percent_var_idx, match_str); - idx += percent_var_idx + match_str.size(); - } - } - } - // Interpret the new command and return this as the result! - if (m_interpreter.GetExpandRegexAliases()) - result.GetOutputStream().Printf("%s\n", new_command.c_str()); - // Pass in true for "no context switching". The command that called us should have set up the context - // appropriately, we shouldn't have to redo that. - return m_interpreter.HandleCommand(new_command.c_str(), eLazyBoolCalculate, result, nullptr, true, true); + if (pos->regex.Execute(command, ®ex_match)) { + 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)) { + const int percent_var_len = + ::snprintf(percent_var, sizeof(percent_var), "%%%u", match_idx); + for (idx = 0; (percent_var_idx = new_command.find( + percent_var, idx)) != std::string::npos;) { + new_command.erase(percent_var_idx, percent_var_len); + new_command.insert(percent_var_idx, match_str); + idx += percent_var_idx + match_str.size(); } + } } - result.SetStatus(eReturnStatusFailed); - if (GetSyntax() != nullptr) - result.AppendError (GetSyntax()); - else - result.AppendErrorWithFormat ("Command contents '%s' failed to match any regular expression in the '%s' regex command.\n", - command, - m_cmd_name.c_str()); - return false; + // Interpret the new command and return this as the result! + if (m_interpreter.GetExpandRegexAliases()) + result.GetOutputStream().Printf("%s\n", new_command.c_str()); + // Pass in true for "no context switching". The command that called us + // should have set up the context + // appropriately, we shouldn't have to redo that. + return m_interpreter.HandleCommand(new_command.c_str(), + eLazyBoolCalculate, result, nullptr, + true, true); + } } - result.AppendError("empty command passed to regular expression command"); result.SetStatus(eReturnStatusFailed); + if (GetSyntax() != nullptr) + result.AppendError(GetSyntax()); + else + result.AppendErrorWithFormat("Command contents '%s' failed to match any " + "regular expression in the '%s' regex " + "command.\n", + command, m_cmd_name.c_str()); return false; + } + result.AppendError("empty command passed to regular expression command"); + result.SetStatus(eReturnStatusFailed); + return false; } - -bool -CommandObjectRegexCommand::AddRegexCommand (const char *re_cstr, const char *command_cstr) -{ - m_entries.resize(m_entries.size() + 1); - // Only add the regular expression if it compiles - if (m_entries.back().regex.Compile (re_cstr)) - { - m_entries.back().command.assign (command_cstr); - return true; - } - // The regex didn't compile... - m_entries.pop_back(); - return false; +bool CommandObjectRegexCommand::AddRegexCommand(const char *re_cstr, + const char *command_cstr) { + m_entries.resize(m_entries.size() + 1); + // Only add the regular expression if it compiles + if (m_entries.back().regex.Compile(re_cstr)) { + m_entries.back().command.assign(command_cstr); + return true; + } + // The regex didn't compile... + m_entries.pop_back(); + return false; } -int -CommandObjectRegexCommand::HandleCompletion (Args &input, - int &cursor_index, - int &cursor_char_position, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches) -{ - if (m_completion_type_mask) - { - std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (GetCommandInterpreter(), - m_completion_type_mask, - completion_str.c_str(), - match_start_point, - max_return_elements, - nullptr, - word_complete, - matches); - return matches.GetSize(); - } - else - { - matches.Clear(); - word_complete = false; - } - return 0; +int CommandObjectRegexCommand::HandleCompletion(Args &input, int &cursor_index, + int &cursor_char_position, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) { + if (m_completion_type_mask) { + std::string completion_str(input.GetArgumentAtIndex(cursor_index), + cursor_char_position); + CommandCompletions::InvokeCommonCompletionCallbacks( + GetCommandInterpreter(), m_completion_type_mask, completion_str.c_str(), + match_start_point, max_return_elements, nullptr, word_complete, + matches); + return matches.GetSize(); + } else { + matches.Clear(); + word_complete = false; + } + return 0; } -- cgit v1.1