Author: Jonas Devlieghere
Date: 2025-12-09T22:36:32Z
New Revision: 9e2b8b0254ccd26dc6f3c7abf053646429d9f15d

URL: 
https://github.com/llvm/llvm-project/commit/9e2b8b0254ccd26dc6f3c7abf053646429d9f15d
DIFF: 
https://github.com/llvm/llvm-project/commit/9e2b8b0254ccd26dc6f3c7abf053646429d9f15d.diff

LOG: [lldb] Remove CommandReturnObject::AppendRawError (#171517)

Remove `CommandReturnObject::AppendRawError` and replace its two uses
with `AppendError`, which correctly prefixes the message with `error:`.
The comment for the method is outdated and the prefixing is clearly
desired in both situations.

Added: 
    

Modified: 
    lldb/include/lldb/Interpreter/CommandReturnObject.h
    lldb/source/Commands/CommandObjectMultiword.cpp
    lldb/source/Interpreter/CommandInterpreter.cpp
    lldb/source/Interpreter/CommandReturnObject.cpp
    lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
    lldb/test/API/functionalities/ambigous_commands/TestAmbiguousCommands.py
    lldb/test/API/functionalities/wrong_commands/TestWrongCommands.py
    lldb/test/Shell/Commands/command-wrong-subcommand-error-msg.test

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h 
b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index 0742f1b836f5e..f6e60840256a4 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -129,8 +129,6 @@ class CommandReturnObject {
 
   void AppendError(llvm::StringRef in_string);
 
-  void AppendRawError(llvm::StringRef in_string);
-
   void AppendErrorWithFormat(const char *format, ...)
       __attribute__((format(printf, 2, 3)));
 

diff  --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index a369557cca845..e08b33cdce940 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -205,7 +205,7 @@ void CommandObjectMultiword::Execute(const char 
*args_string,
             .str());
   }
   error_msg.append("\n");
-  result.AppendRawError(error_msg.c_str());
+  result.AppendError(error_msg);
 }
 
 std::string CommandObjectMultiword::GetSubcommandsHintText() {

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index ffcc9ceeb2a93..cb6acfc9c29a9 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3708,7 +3708,7 @@ CommandInterpreter::ResolveCommandImpl(std::string 
&command_line,
           for (uint32_t i = 0; i < num_matches; ++i) {
             error_msg.Printf("\t%s\n", matches.GetStringAtIndex(i));
           }
-          result.AppendRawError(error_msg.GetString());
+          result.AppendError(error_msg.GetString());
         }
       } else {
         // We didn't have only one match, otherwise we wouldn't get here.

diff  --git a/lldb/source/Interpreter/CommandReturnObject.cpp 
b/lldb/source/Interpreter/CommandReturnObject.cpp
index ef5bfae1bd1bd..85b058e97a679 100644
--- a/lldb/source/Interpreter/CommandReturnObject.cpp
+++ b/lldb/source/Interpreter/CommandReturnObject.cpp
@@ -173,15 +173,6 @@ StructuredData::ObjectSP 
CommandReturnObject::GetErrorData() {
   return Serialize(m_diagnostics);
 }
 
-// Similar to AppendError, but do not prepend 'Status: ' to message, and don't
-// append "\n" to the end of it.
-
-void CommandReturnObject::AppendRawError(llvm::StringRef in_string) {
-  SetStatus(eReturnStatusFailed);
-  assert(!in_string.empty() && "Expected a non-empty error message");
-  GetErrorStream() << in_string;
-}
-
 void CommandReturnObject::SetStatus(ReturnStatus status) { m_status = status; }
 
 ReturnStatus CommandReturnObject::GetStatus() const { return m_status; }

diff  --git a/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py 
b/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
index cc767edaaa619..5dd4f6bee56a3 100644
--- a/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
+++ b/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
@@ -41,7 +41,7 @@ def test_command_abbreviations_and_aliases(self):
         # "pl" could be "platform" or "plugin".
         command_interpreter.ResolveCommand("pl", result)
         self.assertFalse(result.Succeeded())
-        self.assertTrue(result.GetError().startswith("Ambiguous command"))
+        self.assertTrue(result.GetError().startswith("error: Ambiguous 
command"))
 
         # Make sure an unabbreviated command is not mangled.
         command_interpreter.ResolveCommand(

diff  --git 
a/lldb/test/API/functionalities/ambigous_commands/TestAmbiguousCommands.py 
b/lldb/test/API/functionalities/ambigous_commands/TestAmbiguousCommands.py
index 14c66fefea7ef..31b67d72ce469 100644
--- a/lldb/test/API/functionalities/ambigous_commands/TestAmbiguousCommands.py
+++ b/lldb/test/API/functionalities/ambigous_commands/TestAmbiguousCommands.py
@@ -24,7 +24,7 @@ def test_ambiguous_command_with_alias(self):
         self.assertFalse(result.Succeeded())
         self.assertEqual(
             result.GetError(),
-            "Ambiguous command 'co'. Possible 
matches:\n\tcommand\n\tcontinue\n\tcorefile\n",
+            "error: Ambiguous command 'co'. Possible 
matches:\n\tcommand\n\tcontinue\n\tcorefile\n",
         )
 
         command_interpreter.HandleCommand("command unalias continue", result)

diff  --git a/lldb/test/API/functionalities/wrong_commands/TestWrongCommands.py 
b/lldb/test/API/functionalities/wrong_commands/TestWrongCommands.py
index 6d2ce2bb3e709..25f95f3061eb4 100644
--- a/lldb/test/API/functionalities/wrong_commands/TestWrongCommands.py
+++ b/lldb/test/API/functionalities/wrong_commands/TestWrongCommands.py
@@ -17,7 +17,9 @@ def test_ambiguous_command(self):
 
         command_interpreter.HandleCommand("g", result)
         self.assertFalse(result.Succeeded())
-        self.assertRegex(result.GetError(), "Ambiguous command 'g'. Possible 
matches:")
+        self.assertRegex(
+            result.GetError(), "error: Ambiguous command 'g'. Possible 
matches:"
+        )
         self.assertRegex(result.GetError(), "gui")
         self.assertRegex(result.GetError(), "gdb-remote")
         self.assertEqual(1, result.GetError().count("gdb-remote"))

diff  --git a/lldb/test/Shell/Commands/command-wrong-subcommand-error-msg.test 
b/lldb/test/Shell/Commands/command-wrong-subcommand-error-msg.test
index 5365f81c19587..968a4d6fb9682 100644
--- a/lldb/test/Shell/Commands/command-wrong-subcommand-error-msg.test
+++ b/lldb/test/Shell/Commands/command-wrong-subcommand-error-msg.test
@@ -4,5 +4,5 @@
 # RUN: not %lldb -b -o 'breakpoint foo' %t.out -o exit 2>&1 | FileCheck %s 
--check-prefix BP-MSG
 # RUN: not %lldb -b -o 'watchpoint set foo' %t.out -o exit 2>&1 | FileCheck %s 
--check-prefix WP-MSG
 # CHECK: at main.c:2:21
-# BP-MSG: "foo" is not a valid subcommand of "breakpoint". Valid subcommands 
are: add, clear, command, delete, disable, and others. Use "help breakpoint" to 
find out more.
-# WP-MSG: "foo" is not a valid subcommand of "watchpoint set". Valid 
subcommands are: expression, variable. Use "help watchpoint set" to find out 
more.
\ No newline at end of file
+# BP-MSG: error: "foo" is not a valid subcommand of "breakpoint". Valid 
subcommands are: add, clear, command, delete, disable, and others. Use "help 
breakpoint" to find out more.
+# WP-MSG: error: "foo" is not a valid subcommand of "watchpoint set". Valid 
subcommands are: expression, variable. Use "help watchpoint set" to find out 
more.


        
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to