[all-commits] [llvm/llvm-project] e22f1c: [analyzer] Introduce weak dependencies to express ...

Kristóf Umann via All-commits all-commits at lists.llvm.org
Fri Jun 12 05:10:30 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: e22f1c02a27f4471af1b9ae3aa6d8324b86ab2d0
      https://github.com/llvm/llvm-project/commit/e22f1c02a27f4471af1b9ae3aa6d8324b86ab2d0
  Author: Kirstóf Umann <dkszelethus at gmail.com>
  Date:   2020-06-12 (Fri, 12 Jun 2020)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
    M clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
    M clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
    M clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
    M clang/test/Analysis/analyzer-enabled-checkers.c
    A clang/test/Analysis/weak-dependencies.c
    M clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
    M clang/utils/TableGen/ClangSACheckersEmitter.cpp

  Log Message:
  -----------
  [analyzer] Introduce weak dependencies to express *preferred* checker callback evaluation order

Checker dependencies were added D54438 to solve a bug where the checker names
were incorrectly registered, for example, InnerPointerChecker would incorrectly
emit diagnostics under the name MallocChecker, or vice versa [1]. Since the
system over the course of about a year matured, our expectations of what a role
of a dependency and a dependent checker should be crystallized a bit more --
D77474 and its summary, as well as a variety of patches in the stack
demonstrates how we try to keep dependencies to play a purely modeling role. In
fact, D78126 outright forbids diagnostics under a dependency checkers name.

These dependencies ensured the registration order and enabling only when all
dependencies are satisfied. This was a very "strong" contract however, that
doesn't fit the dependency added in D79420. As its summary suggests, this
relation is directly in between diagnostics, not modeling -- we'd prefer a more
specific warning over a general one.

To support this, I added a new dependency kind, weak dependencies. These are not
as strict of a contract, they only express a preference in registration order.
If a weak dependency isn't satisfied, the checker may still be enabled, but if
it is, checker registration, and transitively, checker callback evaluation order
is ensured.

If you are not familiar with the TableGen changes, a rather short description
can be found in the summary of D75360. A lengthier one is in D58065.

[1] https://www.youtube.com/watch?v=eqKeqHRAhQM

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




More information about the All-commits mailing list