[PATCH] D77474: [analyzer][MallocChecker] Make NewDeleteLeaks depend on DynamicMemoryModeling rather than NewDelete
Kristóf Umann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 5 05:19:45 PDT 2020
Szelethus added a comment.
Btw this branch is about 7 months old, and I just now remembered why I haven't rushed publishing it.
My ultimate idea (as opposed to the two detailed in the summary) was to introduce a subchecker system in MallocChecker, which also strongly ties into D67336 <https://reviews.llvm.org/D67336>. The core of the checker (`unix.DynamicMemoryModeling`) would be responsible for dispatching from regular checker callbacks upon seeing a call to a memory management function, and providing the general utilities for modeling it. Smaller subcheckers would then use this interface to implement the modeling of specific functions. For instance, the we could create `NewDeleteChecker`, a subchecker of `DynamicMemoryModeling`, which would get control when stumbling upon a call to a new/delete operator.
This would allow us to spread the implementation into smaller files, which is great, but upon taking a look at D68165 <https://reviews.llvm.org/D68165>, you can see that the bulk of the code isn't really in these modeling functions. For such a change to really make sense, the responsibility of bug emission (like `ReportFunctionPointerFree`) should be moved into the subcheckers as well. This would achieve my goal of smaller, self-contained subcheckers implementing something that we previously did with giants like MallocChecker is now. As to how I should //actually// pull this off (make an event about memory being deallocated to the subcheckers, make them check for bugs? make an event about finding a leak, double delete, etc?) is a different issue, but I'll see what makes more sense, if I choose to go forth with this project.
I do now believe that though that all of these changes would be orthogonal to this one. Just thought I'd share :^).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77474/new/
https://reviews.llvm.org/D77474
More information about the cfe-commits
mailing list