From 0b57cec536236d46e3dba9bd041533462f33dbb7 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Fri, 20 Dec 2019 19:53:05 +0000 Subject: Move all sources from the llvm project into contrib/llvm-project. This uses the new layout of the upstream repository, which was recently migrated to GitHub, and converted into a "monorepo". That is, most of the earlier separate sub-projects with their own branches and tags were consolidated into one top-level directory, and are now branched and tagged together. Updating the vendor area to match this layout is next. --- .../Interpreter/CommandObjectRegexCommand.cpp | 96 ---------------------- 1 file changed, 96 deletions(-) delete mode 100644 contrib/llvm/tools/lldb/source/Interpreter/CommandObjectRegexCommand.cpp (limited to 'contrib/llvm/tools/lldb/source/Interpreter/CommandObjectRegexCommand.cpp') diff --git a/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectRegexCommand.cpp b/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectRegexCommand.cpp deleted file mode 100644 index 19335b95ca3a..000000000000 --- a/contrib/llvm/tools/lldb/source/Interpreter/CommandObjectRegexCommand.cpp +++ /dev/null @@ -1,96 +0,0 @@ -//===-- CommandObjectRegexCommand.cpp ---------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "lldb/Interpreter/CommandObjectRegexCommand.h" - -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -// CommandObjectRegexCommand constructor -CommandObjectRegexCommand::CommandObjectRegexCommand( - CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help, - llvm::StringRef 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() {} - -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, ®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); - } - } - result.SetStatus(eReturnStatusFailed); - if (!GetSyntax().empty()) - result.AppendError(GetSyntax()); - else - result.GetOutputStream() << "Command contents '" << command - << "' failed to match any " - "regular expression in the '" - << m_cmd_name << "' regex "; - 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( - llvm::StringRef::withNullAsEmpty(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(CompletionRequest &request) { - if (m_completion_type_mask) { - CommandCompletions::InvokeCommonCompletionCallbacks( - GetCommandInterpreter(), m_completion_type_mask, request, nullptr); - return request.GetNumberOfMatches(); - } else { - request.SetWordComplete(false); - } - return 0; -} -- cgit v1.2.3