github-actions[bot] wrote: <!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning: <details> <summary> You can test this locally with the following command: </summary> ``````````bash git-clang-format --diff 090850f15dba926e2436089ff679b7015bb59e11 a0b5801ab231670215657ec720fa0c89bc262c04 --extensions h,cpp -- lldb/include/lldb/Interpreter/ScriptInterpreter.h lldb/include/lldb/Utility/CompletionRequest.h lldb/source/Commands/CommandObjectCommands.cpp lldb/source/Interpreter/Options.cpp lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp `````````` </details> <details> <summary> View the diff from clang-format here. </summary> ``````````diff diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h index 6fc9746689..7561585d98 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -436,19 +436,18 @@ public: Args &args) { return std::nullopt; } - - virtual StructuredData::DictionarySP HandleArgumentCompletionForScriptedCommand( - StructuredData::GenericSP impl_obj_sp, std::vector<llvm::StringRef> &args, - size_t args_pos, size_t char_in_arg) - { + + virtual StructuredData::DictionarySP + HandleArgumentCompletionForScriptedCommand( + StructuredData::GenericSP impl_obj_sp, std::vector<llvm::StringRef> &args, + size_t args_pos, size_t char_in_arg) { return {}; } - virtual StructuredData::DictionarySP + virtual StructuredData::DictionarySP HandleOptionArgumentCompletionForScriptedCommand( - StructuredData::GenericSP impl_obj_sp, llvm::StringRef &long_name, - size_t char_in_arg) - { + StructuredData::GenericSP impl_obj_sp, llvm::StringRef &long_name, + size_t char_in_arg) { return {}; } diff --git a/lldb/include/lldb/Utility/CompletionRequest.h b/lldb/include/lldb/Utility/CompletionRequest.h index 242ff38304..650158a197 100644 --- a/lldb/include/lldb/Utility/CompletionRequest.h +++ b/lldb/include/lldb/Utility/CompletionRequest.h @@ -138,7 +138,7 @@ public: const Args::ArgEntry &GetParsedArg() { return GetParsedLine()[GetCursorIndex()]; } - + size_t GetCursorCharPos() const { return m_cursor_char_position; } /// Drops the first argument from the argument list. diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index ec1c4be377..845b89a75b 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1636,16 +1636,16 @@ private: } size_t GetNumOptions() { return m_num_options; } - - void PrepareOptionsForCompletion(CompletionRequest &request, - OptionElementVector &option_vec, - ExecutionContext *exe_ctx) { + + void PrepareOptionsForCompletion(CompletionRequest &request, + OptionElementVector &option_vec, + ExecutionContext *exe_ctx) { // I'm not sure if we'll get into trouble doing an option parsing start // and end in this context. If so, then I'll have to directly tell the // scripter to do this. OptionParsingStarting(exe_ctx); auto opt_defs = GetDefinitions(); - + // Iterate through the options we found so far, and push them into // the scripted side. for (auto option_elem : option_vec) { @@ -1662,26 +1662,30 @@ private: if (cur_arg_pos != OptionArgElement::eUnrecognizedArg && cur_arg_pos != OptionArgElement::eBareDash && cur_arg_pos != OptionArgElement::eBareDoubleDash) { - cur_arg_value = request.GetParsedLine().GetArgumentAtIndex(cur_arg_pos); - + cur_arg_value = + request.GetParsedLine().GetArgumentAtIndex(cur_arg_pos); } } SetOptionValue(cur_defs_index, cur_arg_value, exe_ctx); } OptionParsingFinished(exe_ctx); } - - void ProcessCompletionDict(CompletionRequest &request, StructuredData::DictionarySP &completion_dict_sp) { + + void + ProcessCompletionDict(CompletionRequest &request, + StructuredData::DictionarySP &completion_dict_sp) { // We don't know how to process an empty completion dict, our callers have // to do that. assert(completion_dict_sp && "Must have valid completion dict"); // First handle the case of a single completion: llvm::StringRef completion; // If the dictionary has one element "no-completion" then we return here - if (completion_dict_sp->GetValueForKeyAsString("no-completion", completion)) + if (completion_dict_sp->GetValueForKeyAsString("no-completion", + completion)) return; - if (completion_dict_sp->GetValueForKeyAsString("completion", completion)) { + if (completion_dict_sp->GetValueForKeyAsString("completion", + completion)) { llvm::StringRef mode_str; CompletionMode mode = CompletionMode::Normal; if (completion_dict_sp->GetValueForKeyAsString("mode", mode_str)) { @@ -1708,7 +1712,7 @@ private: if (!val) // FIXME: How do I report this error? return; - + if (descriptions) { auto desc = descriptions->GetItemAtIndexAsString(idx); request.AddCompletion(*val, desc ? *desc : ""); @@ -1717,22 +1721,23 @@ private: } } } - + void HandleOptionArgumentCompletion(lldb_private::CompletionRequest &request, OptionElementVector &option_vec, int opt_element_index, CommandInterpreter &interpreter) override { - ScriptInterpreter *scripter = interpreter.GetDebugger().GetScriptInterpreter(); - + ScriptInterpreter *scripter = + interpreter.GetDebugger().GetScriptInterpreter(); + if (!scripter) return; ExecutionContext exe_ctx = interpreter.GetExecutionContext(); PrepareOptionsForCompletion(request, option_vec, &exe_ctx); - + auto defs = GetDefinitions(); - + size_t defs_index = option_vec[opt_element_index].opt_defs_index; llvm::StringRef option_name = defs[defs_index].long_option; bool is_enum = defs[defs_index].enum_values.size() != 0; @@ -1742,19 +1747,19 @@ private: // regular option completer handle that: StructuredData::DictionarySP completion_dict_sp; if (!is_enum) - completion_dict_sp - = scripter->HandleOptionArgumentCompletionForScriptedCommand(m_cmd_obj_sp, - option_name, request.GetCursorCharPos()); + completion_dict_sp = + scripter->HandleOptionArgumentCompletionForScriptedCommand( + m_cmd_obj_sp, option_name, request.GetCursorCharPos()); if (!completion_dict_sp) { - Options::HandleOptionArgumentCompletion(request, option_vec, + Options::HandleOptionArgumentCompletion(request, option_vec, opt_element_index, interpreter); return; } - + ProcessCompletionDict(request, completion_dict_sp); } - + private: struct EnumValueStorage { EnumValueStorage() { @@ -1995,9 +2000,9 @@ public: Status GetOptionsError() { return m_options_error.Clone(); } Status GetArgsError() { return m_args_error.Clone(); } bool WantsCompletion() override { return true; } - + private: - void PrepareOptionsForCompletion(CompletionRequest &request, + void PrepareOptionsForCompletion(CompletionRequest &request, OptionElementVector &option_vec) { // First, we have to tell the Scripted side to set the values in its // option store, then we call into the handle_completion passing in @@ -2009,28 +2014,28 @@ private: // can just skip setting the options on the scripted side: if (options) m_options.PrepareOptionsForCompletion(request, option_vec, &m_exe_ctx); - } -public: - void HandleArgumentCompletion(CompletionRequest &request, + +public: + void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &option_vec) override { ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter(); - + if (!scripter) return; // Set up the options values on the scripted side: PrepareOptionsForCompletion(request, option_vec); - + // Now we have to make up the argument list. // The ParseForCompletion only identifies tokens in the m_parsed_line // it doesn't remove the options leaving only the args as it does for // the regular Parse, so we have to filter out the option ones using the // option_element_vector: - + Options *options = GetOptions(); - auto defs = options->GetDefinitions(); - + auto defs = options->GetDefinitions(); + std::unordered_set<size_t> option_slots; for (const auto &elem : option_vec) { if (elem.opt_defs_index == -1) @@ -2039,29 +2044,28 @@ public: if (defs[elem.opt_defs_index].option_has_arg) option_slots.insert(elem.opt_arg_pos); } - + std::vector<llvm::StringRef> args_vec; Args &args = request.GetParsedLine(); size_t num_args = args.GetArgumentCount(); size_t cursor_idx = request.GetCursorIndex(); size_t args_elem_pos = cursor_idx; - + for (size_t idx = 0; idx < num_args; idx++) { if (option_slots.count(idx) == 0) args_vec.push_back(args[idx].ref()); - else - if (idx < cursor_idx) - args_elem_pos--; + else if (idx < cursor_idx) + args_elem_pos--; } - StructuredData::DictionarySP completion_dict_sp - = scripter->HandleArgumentCompletionForScriptedCommand(m_cmd_obj_sp, - args_vec, args_elem_pos, request.GetCursorCharPos()); + StructuredData::DictionarySP completion_dict_sp = + scripter->HandleArgumentCompletionForScriptedCommand( + m_cmd_obj_sp, args_vec, args_elem_pos, request.GetCursorCharPos()); if (!completion_dict_sp) { CommandObject::HandleArgumentCompletion(request, option_vec); return; } - + m_options.ProcessCompletionDict(request, completion_dict_sp); } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h index 29c2bb7932..be26064bf2 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h @@ -210,14 +210,15 @@ public: LLDBSwigPythonGetRepeatCommandForScriptedCommand(PyObject *implementor, std::string &command); - static StructuredData::DictionarySP - LLDBSwigPythonHandleArgumentCompletionForScriptedCommand(PyObject *implementor, - std::vector<llvm::StringRef> &args_impl, size_t args_pos, size_t pos_in_arg); - - static StructuredData::DictionarySP - LLDBSwigPythonHandleOptionArgumentCompletionForScriptedCommand(PyObject *implementor, - llvm::StringRef &long_option, size_t pos_in_arg); - + static StructuredData::DictionarySP + LLDBSwigPythonHandleArgumentCompletionForScriptedCommand( + PyObject *implementor, std::vector<llvm::StringRef> &args_impl, + size_t args_pos, size_t pos_in_arg); + + static StructuredData::DictionarySP + LLDBSwigPythonHandleOptionArgumentCompletionForScriptedCommand( + PyObject *implementor, llvm::StringRef &long_option, size_t pos_in_arg); + static bool LLDBSwigPythonCallModuleInit(const char *python_module_name, const char *session_dictionary_name, lldb::DebuggerSP debugger); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 94388b3dac..9045a79d1c 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -2766,10 +2766,10 @@ ScriptInterpreterPythonImpl::GetRepeatCommandForScriptedCommand( return ret_val; } -StructuredData::DictionarySP +StructuredData::DictionarySP ScriptInterpreterPythonImpl::HandleArgumentCompletionForScriptedCommand( - StructuredData::GenericSP impl_obj_sp, std::vector<llvm::StringRef> &args, - size_t args_pos, size_t char_in_arg) { + StructuredData::GenericSP impl_obj_sp, std::vector<llvm::StringRef> &args, + size_t args_pos, size_t char_in_arg) { StructuredData::DictionarySP completion_dict_sp; if (!impl_obj_sp || !impl_obj_sp->IsValid()) return completion_dict_sp; @@ -2778,18 +2778,18 @@ ScriptInterpreterPythonImpl::HandleArgumentCompletionForScriptedCommand( Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock); - completion_dict_sp = - SWIGBridge::LLDBSwigPythonHandleArgumentCompletionForScriptedCommand( - static_cast<PyObject *>(impl_obj_sp->GetValue()), args, args_pos, - char_in_arg); + completion_dict_sp = + SWIGBridge::LLDBSwigPythonHandleArgumentCompletionForScriptedCommand( + static_cast<PyObject *>(impl_obj_sp->GetValue()), args, args_pos, + char_in_arg); } return completion_dict_sp; } -StructuredData::DictionarySP +StructuredData::DictionarySP ScriptInterpreterPythonImpl::HandleOptionArgumentCompletionForScriptedCommand( - StructuredData::GenericSP impl_obj_sp, llvm::StringRef &long_option, - size_t char_in_arg) { + StructuredData::GenericSP impl_obj_sp, llvm::StringRef &long_option, + size_t char_in_arg) { StructuredData::DictionarySP completion_dict_sp; if (!impl_obj_sp || !impl_obj_sp->IsValid()) return completion_dict_sp; @@ -2798,10 +2798,10 @@ ScriptInterpreterPythonImpl::HandleOptionArgumentCompletionForScriptedCommand( Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock); - completion_dict_sp = - SWIGBridge::LLDBSwigPythonHandleOptionArgumentCompletionForScriptedCommand( - static_cast<PyObject *>(impl_obj_sp->GetValue()), long_option, - char_in_arg); + completion_dict_sp = SWIGBridge:: + LLDBSwigPythonHandleOptionArgumentCompletionForScriptedCommand( + static_cast<PyObject *>(impl_obj_sp->GetValue()), long_option, + char_in_arg); } return completion_dict_sp; } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h index 12acc841c9..04d495fad2 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h @@ -174,11 +174,11 @@ public: Args &args) override; StructuredData::DictionarySP HandleArgumentCompletionForScriptedCommand( - StructuredData::GenericSP impl_obj_sp, std::vector<llvm::StringRef> &args, + StructuredData::GenericSP impl_obj_sp, std::vector<llvm::StringRef> &args, size_t args_pos, size_t char_in_arg) override; StructuredData::DictionarySP HandleOptionArgumentCompletionForScriptedCommand( - StructuredData::GenericSP impl_obj_sp, llvm::StringRef &long_options, + StructuredData::GenericSP impl_obj_sp, llvm::StringRef &long_options, size_t char_in_arg) override; Status GenerateFunction(const char *signature, const StringList &input, diff --git a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp index d7a4952642..a2318afdf8 100644 --- a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp +++ b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp @@ -206,19 +206,19 @@ LLDBSwigPythonGetRepeatCommandForScriptedCommand(PyObject *implementor, return std::nullopt; } -StructuredData::DictionarySP -LLDBSwigPythonHandleArgumentCompletionForScriptedCommand(PyObject *implementor, - std::vector<llvm::StringRef> &args, size_t args_pos, size_t pos_in_arg) { +StructuredData::DictionarySP +LLDBSwigPythonHandleArgumentCompletionForScriptedCommand( + PyObject *implementor, std::vector<llvm::StringRef> &args, size_t args_pos, + size_t pos_in_arg) { return {}; } -StructuredData::DictionarySP +StructuredData::DictionarySP LLDBSwigPythonHandleOptionArgumentCompletionForScriptedCommand( - PyObject *implementor, llvm::StringRef &long_options, size_t char_in_arg) { + PyObject *implementor, llvm::StringRef &long_options, size_t char_in_arg) { return {}; } - bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallModuleInit( const char *python_module_name, const char *session_dictionary_name, lldb::DebuggerSP debugger) { `````````` </details> https://github.com/llvm/llvm-project/pull/109062 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits