================
@@ -858,11 +858,21 @@ void
CheckerManager::runCheckersForPrintStateJson(raw_ostream &Out,
++Space;
bool HasMessage = false;
- // Store the last CheckerTag.
- const void *LastCT = nullptr;
+ std::vector<CheckerBackend *> CheckerBackends;
for (const auto &CT : CheckerTags) {
+ CheckerBackend *CB = CT.second.get();
+ CheckerBackends.push_back(CB);
+ }
+ llvm::sort(CheckerBackends,
+ [](const CheckerBackend *First, const CheckerBackend *Last) {
+ return First->getDebugTag() < Last->getDebugTag();
+ });
+
+ // Store the last CheckerBackend.
----------------
NagyDonat wrote:
```suggestion
// Store the last CheckerBackend that had a message, because we need to avoid
// printing a comma after it.
```
The old comment was actively misleading: the last checker backend would be
accessible as `*CheckerBackends.rbegin()` and then you wouldn't need this
fiddly variable.
https://github.com/llvm/llvm-project/pull/235091
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits