[all-commits] [llvm/llvm-project] f2123a: [clang][dataflow] Perform deep copies in copy and ...

martinboehme via All-commits all-commits at lists.llvm.org
Mon Jun 26 06:53:16 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f2123af1e7d7555af92b1bcff91bd5d0679a9b55
      https://github.com/llvm/llvm-project/commit/f2123af1e7d7555af92b1bcff91bd5d0679a9b55
  Author: Martin Braenne <mboehme at google.com>
  Date:   2023-06-26 (Mon, 26 Jun 2023)

  Changed paths:
    M clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
    A clang/include/clang/Analysis/FlowSensitive/RecordOps.h
    M clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
    M clang/include/clang/Analysis/FlowSensitive/Value.h
    M clang/lib/Analysis/FlowSensitive/CMakeLists.txt
    M clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
    A clang/lib/Analysis/FlowSensitive/RecordOps.cpp
    M clang/lib/Analysis/FlowSensitive/Transfer.cpp
    M clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
    A clang/unittests/Analysis/FlowSensitive/RecordOpsTest.cpp
    M clang/unittests/Analysis/FlowSensitive/TestingSupport.h
    M clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

  Log Message:
  -----------
  [clang][dataflow] Perform deep copies in copy and move operations.

This serves two purposes:

- Because, today, we only copy the `StructValue`, modifying the destination of
  the copy also modifies the source. This is demonstrated by the new checks
  added to `CopyConstructor` and `MoveConstructor`, which fail without the
  deep copy.

- It lays the groundwork for eliminating the redundancy between
  `AggregateStorageLocation` and `StructValue`, which will happen as part of the
  ongoing migration to strict handling of value categories (seeo
  https://discourse.llvm.org/t/70086 for details). This will involve turning
  `StructValue` into essentially just a wrapper for `AggregateStorageLocation`;
  under this scheme, the current "shallow" copy (copying a `StructValue` from
  one `AggregateStorageLocation` to another) will no longer be possible.

Because we now perform deep copies, tests need to perform a deep equality
comparison instead of just comparing for equal identity of the `StructValue`s.
The new function `recordsEqual()` provides such a deep equality comparison.

Reviewed By: xazax.hun

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




More information about the All-commits mailing list