This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Introduce `getFieldValue()` test helpers.
ClosedPublic

Authored by mboehme on Jul 11 2023, 2:26 AM.

Details

Summary

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

Diff Detail

Event Timeline

mboehme created this revision.Jul 11 2023, 2:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 2:26 AM
mboehme requested review of this revision.Jul 11 2023, 2:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 2:26 AM
mboehme edited the summary of this revision. (Show Details)
mboehme added inline comments.Jul 11 2023, 2:48 AM
clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
95

Using the opportunity to simplify the code here a bit: If we cast<>, we don't need to assert for non-nullness because cast<> already does that.

gribozavr2 accepted this revision.Jul 11 2023, 4:32 AM
gribozavr2 added a subscriber: gribozavr2.
gribozavr2 added inline comments.
clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
27
This revision is now accepted and ready to land.Jul 11 2023, 4:32 AM
ymandel accepted this revision.Jul 11 2023, 4:57 AM
xazax.hun accepted this revision.Jul 11 2023, 7:17 AM
xazax.hun added inline comments.
clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
94–96
mboehme updated this revision to Diff 539365.Jul 11 2023, 9:41 PM

Changes in response to review comments

mboehme marked 2 inline comments as done.Jul 11 2023, 9:46 PM
This revision was landed with ongoing or failed builds.Jul 11 2023, 9:53 PM
This revision was automatically updated to reflect the committed changes.