https://github.com/NagyDonat commented:

LGTM overall, but I have some minor code quality suggestions.

Perhaps also consider rewriting this whole algorithm in a more straightforward 
and functional manner:
1. Declare a vector `std::vector<std::pair<std::string, std::string>> 
CheckerMsgs;`
2. Foreach `CT` in `CheckerTags`, calculate the corresponding message (with 
`printState`), and if it is nonempty, then push the pair `{CT->getDebugTag(), 
<the message>}` to Contents.
3. Sort `CheckerMsgs` (the default lexicographical order should be equivalent 
to what you're doing now).
4. Loop over `CheckerMsgs` and print its elements with JSON formatting.

You won't need `HasMessage` because you can test whether `CheckerMsgs` is 
empty. You won't need `LastCB` because you can access the last element of 
`CheckerMsgs` e.g. as `*CheckerMsgs.rbegin()`.

As this is just a debug printout, keeping the current tricky logic is also fine 
– decide whether you want to spend extra time on this rewrite. 

https://github.com/llvm/llvm-project/pull/235091
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to