[all-commits] [llvm/llvm-project] 620101: [lldb] Prevent double new lines behind errors/warn...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Wed Feb 24 05:42:36 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6201017d541fb024dfcbe135576d38a97f88b1a3
      https://github.com/llvm/llvm-project/commit/6201017d541fb024dfcbe135576d38a97f88b1a3
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2021-02-24 (Wed, 24 Feb 2021)

  Changed paths:
    M lldb/include/lldb/Interpreter/CommandReturnObject.h
    M lldb/source/Commands/CommandObjectMemory.cpp
    M lldb/source/Interpreter/CommandReturnObject.cpp
    M lldb/test/Shell/Commands/command-disassemble.s

  Log Message:
  -----------
  [lldb] Prevent double new lines behind errors/warning/messages from LLDB commands

The current API for printing errors/warnings/messages from LLDB commands
sometimes adds newlines behind the messages for the caller. However, this
happens unconditionally so when the caller already specified a trailing newline
in the error message (or is trying to print a generated error message that ends
in a newline), LLDB ends up printing both the automatically added newline and
the one that was in the error message string. This leads to all the randomly
appearing new lines in error such as:

```
(lldb) command a
error: 'command alias' requires at least two arguments
(lldb) apropos a b
error: 'apropos' must be called with exactly one argument.

(lldb) why is there an empty line behind the second error?
```

This code adds a check that only appends the new line if the passed message
doesn't already contain a trailing new line.

Also removes the AppendRawWarning which had only one caller and doesn't serve
any purpose now.

Reviewed By: #lldb, mib

Differential Revision: https://reviews.llvm.org/D96947




More information about the All-commits mailing list