[all-commits] [llvm/llvm-project] 0014aa: [clang][dataflow] Use `IntegerValue` instead of `S...

martinboehme via All-commits all-commits at lists.llvm.org
Tue Jul 11 21:52:52 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0014aab2d5882525c23130108e17fbbb5a2120f1
      https://github.com/llvm/llvm-project/commit/0014aab2d5882525c23130108e17fbbb5a2120f1
  Author: Martin Braenne <mboehme at google.com>
  Date:   2023-07-12 (Wed, 12 Jul 2023)

  Changed paths:
    M clang/unittests/Analysis/FlowSensitive/ValueTest.cpp

  Log Message:
  -----------
  [clang][dataflow] Use `IntegerValue` instead of `StructValue` in `ValueTest`.

Soon, it will no longer be possible to default-construct `StructValue`. For details, see https://discourse.llvm.org/t/70086.

For completeness, also add a test that `areEquivalentValues()` on different `IntegerValue`s returns false.

Reviewed By: xazax.hun, gribozavr2

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


  Commit: 2902ea3d817bf381817ff76228c3212f4dc87d47
      https://github.com/llvm/llvm-project/commit/2902ea3d817bf381817ff76228c3212f4dc87d47
  Author: Martin Braenne <mboehme at google.com>
  Date:   2023-07-12 (Wed, 12 Jul 2023)

  Changed paths:
    M clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
    M clang/unittests/Analysis/FlowSensitive/RecordOpsTest.cpp
    M clang/unittests/Analysis/FlowSensitive/TestingSupport.h

  Log Message:
  -----------
  [clang][dataflow] Introduce `getFieldValue()` test helpers.

These insulate tests against changes to the `getChild()` functions of `AggregateStorageLocation` and `StructValue` that will happen as part of the migration to strict handling of value categories (see https://discourse.llvm.org/t/70086 for details):

- `AggregateStorageLocation::getChild()` will soon return a `StorageLocation *`
  instead of a `StorageLocation &`. When this happens, `getFieldValue()` will be
  changed to return null if `AggregateStorageLocation::getChild()` returns null;
  test code will not need to change as it should already be checking whether the
  return value of `getFieldValue()` is null.

- `StructValue::getChild()` will soon return a `StorageLocation *` instead of a
  `Value *`. When this happens, `getFieldValue()` will be changed to look up the
  `Value *` in the `Environment`. Again, test code will not need to change.

The test helpers will continue to serve a useful purpose once the API changes are complete, so the intent is to leave them in place.

This patch changes DataflowEnvironmentTest.cpp and RecordOpsTest.cpp to use the test helpers. TransferTest.cpp will be changed in an upcoming patch to help keep patch sizes manageable for review.

Depends On D154934

Reviewed By: ymandel, xazax.hun, gribozavr2

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


  Commit: 103a0fc0846050dd671e6485ab52491042f905c6
      https://github.com/llvm/llvm-project/commit/103a0fc0846050dd671e6485ab52491042f905c6
  Author: Martin Braenne <mboehme at google.com>
  Date:   2023-07-12 (Wed, 12 Jul 2023)

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

  Log Message:
  -----------
  [clang][dataflow] Use `getFieldValue()` in TransferTest.cpp.

For context, see https://reviews.llvm.org/D154935.

Depends On D154935

Reviewed By: ymandel, xazax.hun

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


  Commit: 1e9b4fc1dcf27ae43477efe0329f738e4419871b
      https://github.com/llvm/llvm-project/commit/1e9b4fc1dcf27ae43477efe0329f738e4419871b
  Author: Martin Braenne <mboehme at google.com>
  Date:   2023-07-12 (Wed, 12 Jul 2023)

  Changed paths:
    M clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

  Log Message:
  -----------
  [clang][dataflow] Various refactorings in TypeErasedDataflowAnalysisTest.cpp

These simplify the code in their own right, but they are also useful in that they minimize the number of changes that will need to be made when then API of `AggregateStorageLocation` and `StructValue` changes as part of the migration to strict handling of value categories (see https://discourse.llvm.org/t/70086).

Depends On D154949

Reviewed By: xazax.hun, gribozavr2

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


  Commit: b47bdcbc7207aac617d3c35dfc029f79b0a46fd8
      https://github.com/llvm/llvm-project/commit/b47bdcbc7207aac617d3c35dfc029f79b0a46fd8
  Author: Martin Braenne <mboehme at google.com>
  Date:   2023-07-12 (Wed, 12 Jul 2023)

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

  Log Message:
  -----------
  [clang][dataflow] Include fields initialized in an `InitListExpr` in `getModeledFields()`.

Previously, we were including these fields only in the specific instance that was initialized by the `InitListExpr`, but not in other instances of the same type. This is inconsistent and error-prone.

Depends On D154952

Reviewed By: xazax.hun, gribozavr2

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


  Commit: bd9b57de4ff7c65be0d69179232ba2d5fe832195
      https://github.com/llvm/llvm-project/commit/bd9b57de4ff7c65be0d69179232ba2d5fe832195
  Author: Martin Braenne <mboehme at google.com>
  Date:   2023-07-12 (Wed, 12 Jul 2023)

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

  Log Message:
  -----------
  [clang][dataflow] Fix initializing a reference field with an `InitListExpr`.

I added a test for this as the ongoing migration to strict handling of value categories (see https://discourse.llvm.org/t/70086) will change the code that handles this case. It turns out we already didn't handle this correctly, so I fixed the existing implementation.

Depends On D154961

Reviewed By: xazax.hun

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


Compare: https://github.com/llvm/llvm-project/compare/5b6b2caf3c6e...bd9b57de4ff7


More information about the All-commits mailing list