[PATCH] D105819: [analyzer] MallocChecker: Add a visitor to leave a note on functions that could have, but did not change ownership on leaked memory

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 12 08:28:12 PDT 2021


Szelethus created this revision.
Szelethus added reviewers: NoQ, vsavchenko, steakhal, martong, ASDenysPetrov.
Szelethus added a project: clang.
Herald added subscribers: manas, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, whisperity, yaxunl.
Szelethus requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.

This is a rather common feedback we get from out leak checkers: bug reports are really short, and are contain barely any usable information on what the analyzer did to conclude that a leak actually happened.

This happens because of our bug report minimizing effort. We construct bug reports by inspecting the `ExplodedNode`s that lead to the error from the bottom up (from the error node all the way to the root of the exploded graph), and mark entities that were the cause of a bug, or have interacted with it as interesting. In order to make the bug report a bit less verbose, whenever we find an entire function call (from `CallEnter` to `CallExitEnd`) that didn't talk about any interesting entity, we prune it (click here <https://www.youtube.com/watch?v=yh2qdnJjizE&ab_channel=LLVM> for more info on bug report generation). Even if the event to highlight is exactly this lack of interaction with interesting entities.

D105553 <https://reviews.llvm.org/D105553> generalized the visitor that creates notes for these cases. This patch adds a new kind of `NoStateChangeVisitor` that leaves notes in functions that took a piece of dynamically allocated memory that later leaked as parameter, and didn't change its ownership status.

While there is some code to talk over in MallocChecker.cpp, the main thing to discuss in my mind are the test cases, where I display where I want to see this visitor end up. I hope to be able to reach a point sometime soon when I can run on this on some real projects and post screenshots about it!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105819

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/NewDeleteLeaks.cpp
  clang/test/Analysis/self-assign.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105819.357949.patch
Type: text/x-patch
Size: 17912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210712/6458e0e6/attachment-0001.bin>


More information about the cfe-commits mailing list