[all-commits] [llvm/llvm-project] 025628: [clang][dataflow] Fix handling of `DeclRefExpr`s t...

Yitzhak Mandelbaum via All-commits all-commits at lists.llvm.org
Wed Feb 1 05:23:50 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 02562804d074a4d6e041e00572483fe25932186e
      https://github.com/llvm/llvm-project/commit/02562804d074a4d6e041e00572483fe25932186e
  Author: Yitzhak Mandelbaum <yitzhakm at google.com>
  Date:   2023-02-01 (Wed, 01 Feb 2023)

  Changed paths:
    M clang/lib/Analysis/FlowSensitive/Transfer.cpp
    M clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

  Log Message:
  -----------
  [clang][dataflow] Fix handling of `DeclRefExpr`s to `BindingDecl`s.

The invariants around `ReferenceValues` are subtle (arguably, too much so). That
includes that we need to take care not to double wrap them -- in cases where we
wrap a loc in an `ReferenceValue` we need to be sure that the pointee isn't
already a `ReferenceValue`.  `BindingDecl` introduces another situation in which
this can arise. Previously, the code did not properly handle `BindingDecl`,
resulting in double-wrapped values, which broke other invariants (at least, that
struct values have an `AggregateStorageLocation`).

This patch adjusts the interpretation of `DeclRefExpr` to take `BindingDecl`'s
peculiarities into account. It also fixes the two tests which should have caught
this issue but were themselves (subtly) buggy.

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




More information about the All-commits mailing list