[all-commits] [llvm/llvm-project] 104f5d: [analyzer] Introduce the check::BlockEntrance chec...

Balázs Benics via All-commits all-commits at lists.llvm.org
Tue May 27 01:11:33 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 104f5d1ff84613542442b71bcb59e19c5ed17b89
      https://github.com/llvm/llvm-project/commit/104f5d1ff84613542442b71bcb59e19c5ed17b89
  Author: Balázs Benics <108414871+balazs-benics-sonarsource at users.noreply.github.com>
  Date:   2025-05-27 (Tue, 27 May 2025)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/Checker.h
    M clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
    M clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
    M clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
    M clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
    M clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
    M clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
    M clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
    A clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp
    M clang/unittests/StaticAnalyzer/CMakeLists.txt

  Log Message:
  -----------
  [analyzer] Introduce the check::BlockEntrance checker callback (#140924)

Tranersing the CFG blocks of a function is a fundamental operation. Many
C++ constructs can create splits in the control-flow, such as `if`,
`for`, and similar control structures or ternary expressions, gnu
conditionals, gotos, switches and possibly more.

Checkers should be able to get notifications about entering or leaving a
CFG block of interest.

Note that in the ExplodedGraph there is always a BlockEntrance
ProgramPoint right after the BlockEdge ProgramPoint. I considered naming
this callback check::BlockEdge, but then that may leave the observer of
the graph puzzled to see BlockEdge points followed more BlockEdge nodes
describing the same CFG transition. This confusion could also apply to
Bug Report Visitors too.

Because of this, I decided to hook BlockEntrance ProgramPoints instead.
The same confusion applies here, but I find this still a better place
TBH. There would only appear only one BlockEntrance ProgramPoint in the
graph if no checkers modify the state or emit a bug report. Otherwise
they modify some GDM (aka. State) thus create a new ExplodedNode with
the same BlockEntrance ProgramPoint in the graph.

CPP-6484



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list