[all-commits] [llvm/llvm-project] 2d3668: [analyzer] MallocChecker: Add a visitor to leave a...

Kristóf Umann via All-commits all-commits at lists.llvm.org
Mon Aug 16 07:19:29 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2d3668c997faac1f64cd3b8eb336af989069d135
      https://github.com/llvm/llvm-project/commit/2d3668c997faac1f64cd3b8eb336af989069d135
  Author: Kristóf Umann <dkszelethus at gmail.com>
  Date:   2021-08-16 (Mon, 16 Aug 2021)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
    M clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
    A clang/test/Analysis/NewDeleteLeaks.cpp
    M clang/test/Analysis/analyzer-config.c

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

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 ExplodedNodes 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 for more info on bug
report generation). Even if the event to highlight is exactly this lack of
interaction with interesting entities.

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.

Differential Revision: https://reviews.llvm.org/D105553




More information about the All-commits mailing list