Skip to content

[lldb] Remove redundant severity substring within a diagnostic message #8140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lldb/source/Expression/DiagnosticManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,20 @@ static const char *StringForSeverity(DiagnosticSeverity severity) {

std::string DiagnosticManager::GetString(char separator) {
std::string ret;
llvm::raw_string_ostream stream(ret);

for (const auto &diagnostic : Diagnostics()) {
ret.append(StringForSeverity(diagnostic->GetSeverity()));
ret.append(std::string(diagnostic->GetMessage()));
ret.push_back(separator);
llvm::StringRef severity = StringForSeverity(diagnostic->GetSeverity());
stream << severity;

llvm::StringRef message = diagnostic->GetMessage();
std::string searchable_message = message.lower();
auto severity_pos = message.find(severity);
stream << message.take_front(severity_pos);

if (severity_pos != llvm::StringRef::npos)
stream << message.drop_front(severity_pos + severity.size());
stream << separator;
}

return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test(self):
"expr @import LLDBTestModule",
error=True,
substrs=[
"module.h:4:1: error: unknown type name 'syntax_error_for_lldb_to_find'",
"module.h:4:1: unknown type name 'syntax_error_for_lldb_to_find'",
"syntax_error_for_lldb_to_find // comment that tests source printing",
"could not build module 'LLDBTestModule'",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def do_test(self):
self.assertTrue(is_error)
error = self.get_stream_data(result)
self.assertIn("left side of mutating operator", error, "Error messages do not match")
self.assertIn(":15:3: error: left side of mutating operator", error, "Error line number does not match")
self.assertIn(":15:3: left side of mutating operator", error, "Error line number does not match")

# Execute revised block
result, output = self.execute_code("Input3.swift")
Expand Down
4 changes: 2 additions & 2 deletions lldb/test/Shell/SwiftREPL/DiagnosticOptions.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


_ = "An unterminated string
// DIAGNOSTIC: error: unterminated string literal [lex_unterminated_string]{{$}}
// LOCALIZED: error: chaîne non terminée littérale{{$}}
// DIAGNOSTIC: unterminated string literal [lex_unterminated_string]{{$}}
// LOCALIZED: chaîne non terminée littérale{{$}}
:quit


Expand Down
2 changes: 1 addition & 1 deletion lldb/test/Shell/SwiftREPL/ImportError.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
// RUN: %lldb --repl < %s 2>&1 | FileCheck %s

import ModuleThatDoesNotExist
// CHECK: error: no such module 'ModuleThatDoesNotExist'
// CHECK: no such module 'ModuleThatDoesNotExist'
// CHECK-NOT: fixed expression suggested
2 changes: 1 addition & 1 deletion lldb/test/Shell/SwiftREPL/LookupAfterImport.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// RUN: %lldb --repl="-I%t -L%t -lA" < %s 2>&1 | FileCheck %s

"".foo()
// CHECK: error: value of type 'String' has no member 'foo'
// CHECK: value of type 'String' has no member 'foo'

import A

Expand Down
2 changes: 1 addition & 1 deletion lldb/test/Shell/SwiftREPL/LookupWithAttributedImport.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let y = Bar(baz: 123)
// CHECK: baz = 123

let x = Foo(bar:42)
// CHECK: error: repl.swift:{{.*}}: error: cannot find 'Foo' in scope
// CHECK: error: repl.swift:{{.*}}: cannot find 'Foo' in scope

@testable import Test

Expand Down
2 changes: 1 addition & 1 deletion lldb/test/Shell/SwiftREPL/OpenClass.test
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class Baz: Foo {
override func foo() -> Int { return 4 }
}

// CHECK: error: overriding non-open instance method outside of its defining module
// CHECK: overriding non-open instance method outside of its defining module
2 changes: 1 addition & 1 deletion lldb/test/Shell/SwiftREPL/PropertyWrapperTopLevel.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@

@A var anA: Int = 1

// CHECK: error: property wrappers are not yet supported in top-level code
// CHECK: property wrappers are not yet supported in top-level code
// CHECK-NEXT: @A var anA: Int = 1