[all-commits] [llvm/llvm-project] 0cc310: [analyzer] Introduce a new interface for tracking

Valeriy Savchenko via All-commits all-commits at lists.llvm.org
Fri Jun 11 02:52:03 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0cc3100bf8d126ce080c0075cf25784b45e5f990
      https://github.com/llvm/llvm-project/commit/0cc3100bf8d126ce080c0075cf25784b45e5f990
  Author: Valeriy Savchenko <vsavchenko at apple.com>
  Date:   2021-06-11 (Fri, 11 Jun 2021)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
    M clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

  Log Message:
  -----------
  [analyzer] Introduce a new interface for tracking

Tracking values through expressions and the stores is fundamental
for producing clear diagnostics.  However, the main components
participating in this process, namely `trackExpressionValue` and
`FindLastStoreBRVisitor`, became pretty bloated.  They have an
interesting dynamic between them (and some other visitors) that
one might call a "chain reaction". `trackExpressionValue` adds
`FindLastStoreBRVisitor`, and the latter calls `trackExpressionValue`.

Because of this design, individual checkers couldn't affect what's
going to happen somewhere in the middle of that chain.  Whether they
want to produce a more informative note or keep the overall tracking
going by utilizing some of the domain expertise.  This all lead to two
biggest problems that I see:

  * Some checkers don't use it
  This should probably never be the case for path-sensitive checks.

  * Some checkers incorporated their logic directly into those
    components
  This doesn't make the maintenance easier, breaks multiple
  architecture principles, and makes the code harder to read adn
  understand, thus, increasing the probability of the first case.

This commit introduces a prototype for a new interface that will be
responsible for tracking.  My main idea here was to make operations
that I want have as a checker developer easy to implement and hook
directly into the tracking process.

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


  Commit: 967c06b3e95ba776fb06ad0ea5aa699cf2e1b59a
      https://github.com/llvm/llvm-project/commit/967c06b3e95ba776fb06ad0ea5aa699cf2e1b59a
  Author: Valeriy Savchenko <vsavchenko at apple.com>
  Date:   2021-06-11 (Fri, 11 Jun 2021)

  Changed paths:
    M clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

  Log Message:
  -----------
  [analyzer] Reimplement trackExpressionValue as ExpressionHandler

This commit moves trackExpressionValue into the Tracker interface
as DefaultExpressionHandler.  It still can be split into smaller
handlers, but that can be a future change.

Additionally, this commit doesn't remove the original trackExpressionValue
interface, so it's not too big.  One of the next commits will address it.

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


  Commit: b6bcf953220db7880f2bb508f6f5c02b41078b2c
      https://github.com/llvm/llvm-project/commit/b6bcf953220db7880f2bb508f6f5c02b41078b2c
  Author: Valeriy Savchenko <vsavchenko at apple.com>
  Date:   2021-06-11 (Fri, 11 Jun 2021)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
    M clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
    M clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
    M clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

  Log Message:
  -----------
  [analyzer] Change FindLastStoreBRVisitor to use Tracker

Additionally, this commit completely removes any uses of
FindLastStoreBRVisitor from the analyzer except for the
one in Tracker.

The next step is actually removing this class altogether
from the header file.

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


  Commit: 87a5c4d3745a06ec0594fa3f7aaf7f58a53315ec
      https://github.com/llvm/llvm-project/commit/87a5c4d3745a06ec0594fa3f7aaf7f58a53315ec
  Author: Valeriy Savchenko <vsavchenko at apple.com>
  Date:   2021-06-11 (Fri, 11 Jun 2021)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
    M clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

  Log Message:
  -----------
  [analyzer] Hide and rename FindLastStoreBRVisitor

This component should not be used directly at this point and it is
simply an implementation detail, that's why StoreSiteFinder is
out of the header file.

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


  Commit: f853d2601abd4f6ab789ca1513ae8b59ba5d38b7
      https://github.com/llvm/llvm-project/commit/f853d2601abd4f6ab789ca1513ae8b59ba5d38b7
  Author: Valeriy Savchenko <vsavchenko at apple.com>
  Date:   2021-06-11 (Fri, 11 Jun 2021)

  Changed paths:
    M clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

  Log Message:
  -----------
  [analyzer] Turn ReturnVisitor into a tracking visitor

Whenever Tracker spawns a visitor that needs to call tracker
back, we have to use TrackingBugReporterVisitor in order to maintain
all the hooks that the checker might've used.

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


  Commit: 3fc8d943c360f801a428ff24569d2dd53a2afe0f
      https://github.com/llvm/llvm-project/commit/3fc8d943c360f801a428ff24569d2dd53a2afe0f
  Author: Valeriy Savchenko <vsavchenko at apple.com>
  Date:   2021-06-11 (Fri, 11 Jun 2021)

  Changed paths:
    M clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

  Log Message:
  -----------
  [analyzer] Refactor trackRValueExpression into ExpressionHandler

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


  Commit: 51d4704d5ec9b8e4e5e445ee69c56a58250e370e
      https://github.com/llvm/llvm-project/commit/51d4704d5ec9b8e4e5e445ee69c56a58250e370e
  Author: Valeriy Savchenko <vsavchenko at apple.com>
  Date:   2021-06-11 (Fri, 11 Jun 2021)

  Changed paths:
    M clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

  Log Message:
  -----------
  [analyzer] Turn TrackControlDependencyCond into a tracking visitor

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


  Commit: 57006d2f6d96d8a6836ae901218ed615071b3b8e
      https://github.com/llvm/llvm-project/commit/57006d2f6d96d8a6836ae901218ed615071b3b8e
  Author: Valeriy Savchenko <vsavchenko at apple.com>
  Date:   2021-06-11 (Fri, 11 Jun 2021)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
    M clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
    M clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

  Log Message:
  -----------
  [analyzer] Refactor trackExpressionValue to accept TrackingOptions

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


Compare: https://github.com/llvm/llvm-project/compare/20542b47d637...57006d2f6d96


More information about the All-commits mailing list