[Lldb-commits] [lldb] [lldb] Improve rendering of inline diagnostics on the same column (PR #116727)
Felipe de Azevedo Piovezan via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 19 09:29:08 PST 2024
================
@@ -130,6 +131,25 @@ void RenderDiagnosticDetails(Stream &stream,
}
stream << '\n';
+ // Reverse the order within groups of diagnostics that are on the same column.
+ auto group = [](const std::vector<DiagnosticDetail> &details) {
+ uint16_t column = 0;
+ std::vector<DiagnosticDetail> result, group;
+ for (auto &d : details) {
+ if (d.source_location->column == column) {
+ group.push_back(d);
+ continue;
+ }
+ result.insert(result.end(), group.rbegin(), group.rend());
+ group.clear();
+ column = d.source_location->column;
+ group.push_back(d);
+ }
+ result.insert(result.end(), group.rbegin(), group.rend());
+ return result;
+ };
+ remaining_details = group(remaining_details);
+
----------------
felipepiovezan wrote:
I think this is way more complicated than it should be, and it is one of those rare cases where iterators are very helpful:
```
auto group = [](llvm::ArrayRef<DiagnosticDetail> details) {
std::vector<DiagnosticDetail> result;
for (auto it = details.begin(), end = details.end(); it != end;) {
auto eq_end = std::find_if(it, end, [&](const DiagnosticDetail &d) {
return d.source_location->column != it->source_location->column;
});
std::reverse_copy(it, eq_end, std::back_inserter(result));
it = eq_end;
}
return result;
};
```
https://github.com/llvm/llvm-project/pull/116727
More information about the lldb-commits
mailing list