[Lldb-commits] [lldb] [lldb] Make sure completions don't end with newlines (PR #117054)

via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 20 13:25:39 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

<details>
<summary>Changes</summary>

The logic that prints completions and their descriptions assumes neither the completion itself nor the description ends with a newline. I considered making this an assert, but decided against it as completions can indirectly come from user input (e.g. oddly crafted names). Instead, avoid the potential for mistakes by defensively stripping them.

---
Full diff: https://github.com/llvm/llvm-project/pull/117054.diff


1 Files Affected:

- (modified) lldb/include/lldb/Utility/CompletionRequest.h (+2-2) 


``````````diff
diff --git a/lldb/include/lldb/Utility/CompletionRequest.h b/lldb/include/lldb/Utility/CompletionRequest.h
index 650158a197dbd9..865d6db5762984 100644
--- a/lldb/include/lldb/Utility/CompletionRequest.h
+++ b/lldb/include/lldb/Utility/CompletionRequest.h
@@ -52,8 +52,8 @@ class CompletionResult {
   public:
     Completion(llvm::StringRef completion, llvm::StringRef description,
                CompletionMode mode)
-        : m_completion(completion.str()), m_descripton(description.str()),
-          m_mode(mode) {}
+        : m_completion(completion.rtrim().str()),
+          m_descripton(description.rtrim().str()), m_mode(mode) {}
     const std::string &GetCompletion() const { return m_completion; }
     const std::string &GetDescription() const { return m_descripton; }
     CompletionMode GetMode() const { return m_mode; }

``````````

</details>


https://github.com/llvm/llvm-project/pull/117054


More information about the lldb-commits mailing list