This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Remove private-field filtering from `StorageLocation` creation.
ClosedPublic

Authored by ymandel on May 25 2022, 1:42 PM.

Details

Summary

The API for AggregateStorageLocation does not allow for missing fields (it asserts). Therefore, it is incorrect to filter out any fields at location-creation time which may be accessed by the code. Currently, we limit filtering to private, base-calss fields on the assumption that those can never be accessed. However, friend declarations can invalidate that assumption, thereby breaking our invariants.

This patch removes said field filtering to avoid violating the invariant of "no missing fields" for AggregateStorageLocation.

Diff Detail

Event Timeline

ymandel created this revision.May 25 2022, 1:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2022, 1:42 PM
ymandel requested review of this revision.May 25 2022, 1:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2022, 1:42 PM
sgatev added inline comments.May 25 2022, 2:02 PM
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
381

Why not use getObjectFields here too?

497

Why not use getObjectFields here too?

clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
1274–1275

Might as well check that Foo.Bar is assigned a value like the DerivedBaseMemberClass test case?

ymandel updated this revision to Diff 432249.May 26 2022, 5:08 AM

address review comments

ymandel marked 3 inline comments as done.May 26 2022, 5:09 AM
ymandel added inline comments.
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
381

We could. I figured it was still worth the optimization on the values. Usually, its correct and otherwise we lose some precision. But, now that you asked, I'm inclined to get rid of it altogether -- seems like we should have evidence of the benefit in practice before adopt an approach that we know costs us precision (in potentially surprising ways).

xazax.hun accepted this revision.May 26 2022, 9:00 AM
This revision is now accepted and ready to land.May 26 2022, 9:00 AM
sgatev accepted this revision.May 26 2022, 11:22 PM
This revision was landed with ongoing or failed builds.May 27 2022, 6:53 AM
This revision was automatically updated to reflect the committed changes.
ymandel marked an inline comment as done.