[PATCH] D68162: [analyzer][MallocChecker][NFC] Communicate the allocation family information to auxiliary functions with template parameters

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 27 15:11:37 PDT 2019


Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, rnkovacs, Charusso, dcoughlin, baloghadamsoftware.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, szepet, whisperity.

The following series of refactoring patches aim to fix the horrible mess that MallocChecker.cpp is.

I genuinely hate this file. It goes completely against how most of the checkers are implemented, its by far the biggest headache regarding checker dependencies, checker options, or anything you can imagine. On top of all that, its just bad code. Its seriously everything that you shouldn't do in C++, or any other language really. Bad variable/class names, in/out parameters... Apologies, rant over.

So: there are a variety of memory manipulating function this checker models. One aspect of these functions is their `AllocationFamily`, which we use to distinguish between allocation kinds, like using `free()` on an object allocated by `operator new`. However, since we always know which function we're actually modeling, in fact we know it //compile time//, there is no need to use tricks to retrieve this information out of thin air n+1 function calls down the line. This patch changes many methods of `MallocChecker` to take a non-optional `AllocationFamily` template parameter (which also makes stack dumps a bit nicer!), and removes some no longer needed auxiliary functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68162

Files:
  clang/lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68162.222249.patch
Type: text/x-patch
Size: 37372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190927/a1fa7176/attachment-0001.bin>


More information about the cfe-commits mailing list