[clang] [analyzer] Modernize FuchsiaHandleChecker (PR #111588)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 9 03:54:22 PDT 2024


https://github.com/NagyDonat commented:

I read the patch and added my suggestions in inline comments, but I don't promise that I found every little corner case.

Moreover, I'm strongly opposed to introducing a `BugReporterVisitor` instead of directly creating the notes, because in this case you *already know* the locations where you want to add the notes (because that's where you update the `HandleState`), so it's completely pointless to delay the note creation to an awkward indirect post-procession step performed by a visitor. This way you wouldn't need to complicate the handle state by adding the (otherwise completely irrelevant) argument index in it.

In general, bug reporter visitors are complex tools that are good for complex situations where you want to find arbitrary complicated patterns in the bug report path, but should be avoided in simpler cases.

Admittedly, the old note creation code looks like an Obfuscated C Code Contest entry, but if you clear it up by introducing a few "natural" helper functions, you'll get an implementation that's significantly easier to understand than the "hide these numbers in the state, then later come back and reconstruct the situation" visitor.

https://github.com/llvm/llvm-project/pull/111588


More information about the cfe-commits mailing list