[Lldb-commits] [lldb] [lldb] Remove redundant severity substring within a diagnostic message. (PR #76111)
Pete Lawrence via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 21 13:17:20 PST 2023
================
@@ -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) redundant 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);
----------------
PortalPete wrote:
I don't know how hot it is either but, I do know `UserExpression.cpp` has 2 call sites, which may be a popular path.
There's about 15 call sites from these files:
* `lldb/include/lldb/Expression/DiagnosticManager.h`
* `lldb/source/Breakpoint/BreakpointLocation.cpp`
* `lldb/source/Expression/DiagnosticManager.cpp`
* `lldb/source/Expression/UserExpression.cpp`
* `lldb/source/Expression/UtilityFunction.cpp`
* `lldb/source/Interpreter/CommandReturnObject.cpp`
* `lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp`
* `lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp`
* `lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp`
* `lldb/source/Target/Target.cpp`
* `lldb/source/Utility/Status.cpp`
The one from `DiagnosticManager.h` is its `Dump()` method which itself has 7 call sites.
I have a future PR that'll move this functionality into `class Status`, and whatever we decided to do here we can do there as well.
https://github.com/llvm/llvm-project/pull/76111
More information about the lldb-commits
mailing list