[all-commits] [llvm/llvm-project] 9fd7ce: [analyzer][MallocChecker][NFC] Communicate the all...

Kristóf Umann via All-commits all-commits at lists.llvm.org
Tue Feb 25 02:17:40 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9fd7ce7f4449619bc85ab4d2643e656836a2d5e2
      https://github.com/llvm/llvm-project/commit/9fd7ce7f4449619bc85ab4d2643e656836a2d5e2
  Author: Kristóf Umann <dkszelethus at gmail.com>
  Date:   2020-02-25 (Tue, 25 Feb 2020)

  Changed paths:
    M clang/lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
    M clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

  Log Message:
  -----------
  [analyzer][MallocChecker][NFC] Communicate the allocation family to auxiliary functions with parameters

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.

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




More information about the All-commits mailing list