Skip to content

[lldb][NFC] Avoid an assertion failure in dwim-print #139197

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
merged 3 commits into from
May 9, 2025
Merged
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
13 changes: 6 additions & 7 deletions lldb/source/Utility/DiagnosticsRendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ void RenderDiagnosticDetails(Stream &stream,

// Work through each detail in reverse order using the vector/stack.
bool did_print = false;
for (auto detail = remaining_details.rbegin();
detail != remaining_details.rend();
++detail, remaining_details.pop_back()) {
for (; !remaining_details.empty(); remaining_details.pop_back()) {
const auto &detail = remaining_details.back();
// Get the information to print this detail and remove it from the stack.
// Print all the lines for all the other messages first.
stream << std::string(padding, ' ');
Expand All @@ -196,7 +195,7 @@ void RenderDiagnosticDetails(Stream &stream,
llvm::ArrayRef(remaining_details).drop_back(1)) {
uint16_t column = remaining_detail.source_location->column;
// Is this a note with the same column as another diagnostic?
if (column == detail->source_location->column)
if (column == detail.source_location->column)
continue;

if (column >= x_pos) {
Expand All @@ -205,16 +204,16 @@ void RenderDiagnosticDetails(Stream &stream,
}
}

uint16_t column = detail->source_location->column;
uint16_t column = detail.source_location->column;
// Print the line connecting the ^ with the error message.
if (column >= x_pos)
stream << std::string(column - x_pos, ' ') << joint << hbar << spacer;

// Print a colorized string based on the message's severity type.
PrintSeverity(stream, detail->severity);
PrintSeverity(stream, detail.severity);

// Finally, print the message and start a new line.
stream << detail->message << '\n';
stream << detail.message << '\n';
did_print = true;
}

Expand Down
Loading