llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Pete Lawrence (PortalPete) <details> <summary>Changes</summary> For example, the following message has the severity string "error: " twice. > "error: <EXPR>:3:1: error: cannot find 'bogus' in scope This method already appends the severity string in the beginning, but with this fix, it also removes a secondary instance, if applicable. Note that this change only removes the *first* redundant substring. I considered putting the removal logic in a loop, but I decided that if something is generating more than one redundant severity substring, then that's a problem the message's source should probably fix. rdar://114203423 --- Full diff: https://github.com/llvm/llvm-project/pull/76111.diff 2 Files Affected: - (modified) lldb/source/Expression/DiagnosticManager.cpp (+11-2) - (modified) lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py (+1-1) ``````````diff diff --git a/lldb/source/Expression/DiagnosticManager.cpp b/lldb/source/Expression/DiagnosticManager.cpp index 08977066e3330a..d9452328e5a27f 100644 --- a/lldb/source/Expression/DiagnosticManager.cpp +++ b/lldb/source/Expression/DiagnosticManager.cpp @@ -48,8 +48,17 @@ std::string DiagnosticManager::GetString(char separator) { std::string ret; for (const auto &diagnostic : Diagnostics()) { - ret.append(StringForSeverity(diagnostic->GetSeverity())); - ret.append(std::string(diagnostic->GetMessage())); + std::string message(diagnostic->GetMessage()); + std::string searchable_message(diagnostic->GetMessage().lower()); + std::string severity(StringForSeverity(diagnostic->GetSeverity())); + + // Erase the (first) reduntant severity string in the message. + size_t position = searchable_message.find(severity); + if (position != std::string::npos) + message.erase(position, severity.length()); + + ret.append(severity); + ret.append(message); ret.push_back(separator); } diff --git a/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py b/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py index 36e302be2525b5..620b6e44fc852a 100644 --- a/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py +++ b/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py @@ -21,7 +21,7 @@ def test(self): "expr @import LLDBTestModule", error=True, substrs=[ - "module.h:4:1: error: use of undeclared identifier 'syntax_error_for_lldb_to_find'", + "module.h:4:1: use of undeclared identifier 'syntax_error_for_lldb_to_find'", "syntax_error_for_lldb_to_find // comment that tests source printing", "could not build module 'LLDBTestModule'", ], `````````` </details> https://github.com/llvm/llvm-project/pull/76111 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits