From 4d51a90297d34389b53c00c5cd6fa6f73998c298 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 12 Jul 2018 22:28:52 +0000 Subject: Get rid of the C-string parameter in DoExecute Summary: This patch gets rid of the C-string parameter in the RawCommandObject::DoExecute function, making the code simpler and less memory unsafe. There seems to be a assumption in some command objects that this parameter could be a nullptr, but from what I can see the rest of the API doesn't actually allow this (and other command objects and related code pieces dereference this parameter without any checks). Especially CommandObjectRegexCommand has error handling code for a nullptr that is now gone. Reviewers: davide, jingham, teemperor Reviewed By: teemperor Subscribers: jingham, lldb-commits Differential Revision: https://reviews.llvm.org/D49207 llvm-svn: 336955 --- lldb/source/Commands/CommandObjectCommands.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lldb/source/Commands/CommandObjectCommands.cpp') diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 5e7f272ec22..b7f439e5219 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -543,9 +543,9 @@ rather than using a positional placeholder:" ~CommandObjectCommandsAlias() override = default; protected: - bool DoExecute(const char *raw_command_line, + bool DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override { - if (!raw_command_line || !raw_command_line[0]) { + if (raw_command_line.empty()) { result.AppendError("'command alias' requires at least two arguments"); return false; } @@ -1275,7 +1275,7 @@ public: } protected: - bool DoExecute(const char *raw_command_line, + bool DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override { ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter(); @@ -1364,7 +1364,7 @@ public: } protected: - bool DoExecute(const char *raw_command_line, + bool DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override { ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter(); -- cgit v1.2.3