[all-commits] [llvm/llvm-project] cfd202: [clang][dataflow] Add a callback run on the pre-tr...

martinboehme via All-commits all-commits at lists.llvm.org
Thu Jun 20 21:52:52 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cfd202141069809c3c65b8b49d3896f44ff10a6a
      https://github.com/llvm/llvm-project/commit/cfd202141069809c3c65b8b49d3896f44ff10a6a
  Author: martinboehme <mboehme at google.com>
  Date:   2024-06-21 (Fri, 21 Jun 2024)

  Changed paths:
    M clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
    M clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
    M clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
    M clang/unittests/Analysis/FlowSensitive/TestingSupport.h
    M clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

  Log Message:
  -----------
  [clang][dataflow] Add a callback run on the pre-transfer state. (#96140)

At the same time, rename `PostVisitCFG` to the more descriptive
`PostAnalysisCallbacks` (which emphasizes the fact that these callbacks
are run
after the dataflow analysis itself has converged).

Before this patch, it was only possible to run a callback on the state
_after_
the transfer function had been applied, but for many analyses, it's more
natural
to to check the state _before_ the transfer function has been applied,
because we
are usually checking the preconditions for some operation. Some checks
are
impossible to perform on the "after" state because we can no longer
check the
precondition; for example, the `++` / `--` operators on raw pointers
require the
operand to be nonnull, but after the transfer function for the operator
has been
applied, the original value of the pointer can no longer be accessed.

`UncheckedOptionalAccessModelTest` has been modified to run the
diagnosis
callback on the "before" state. In this particular case, diagnosis can
be run
unchanged on either the "before" or "after" state, but we want this test
to
demonstrate that running diagnosis on the "before" state is usually the
preferred approach.

This change is backwards-compatible; all existing analyses will continue
to run
the callback on the "after" state.



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