This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Add equivalence relation for `Value` type.
ClosedPublic

Authored by ymandel on Oct 14 2022, 9:07 AM.

Details

Summary

Defines an equivalence relation on the Value type to standardize several
places in the code where we replicate the ~same equivalence comparison.

Diff Detail

Event Timeline

ymandel created this revision.Oct 14 2022, 9:07 AM
Herald added a project: Restricted Project. · View Herald Transcript
ymandel requested review of this revision.Oct 14 2022, 9:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 9:07 AM

Reviewers: I'm inclined towards a method vs overloaded operator. Please let me know.

xazax.hun accepted this revision.Oct 14 2022, 9:21 AM
xazax.hun added inline comments.
clang/lib/Analysis/FlowSensitive/Value.cpp
38

I started to wonder, is it always the case that we want properties to be part of the identity for values? Especially when we have multiple checks collaborating in the same fixed-point iteration, the properties added by one check might not be interesting for the others, and influencing what values are considered equal is a way to "leak" this information between checks.

Feel free to leave it as is for now, I just wanted to make sure we think about this at some point in the future :)

This revision is now accepted and ready to land.Oct 14 2022, 9:21 AM

Reviewers: I'm inclined towards a method vs overloaded operator. Please let me know.

I don't have a strong preference. But in case we come up with multiple kinds of equalities (see my comment about the properties) methods might work better.

ymandel retitled this revision from [clang][dataflow] Add `operator==` for `Value` type. to [clang][dataflow] Add equivalence relation for `Value` type..Oct 14 2022, 11:20 AM
ymandel edited the summary of this revision. (Show Details)
ymandel updated this revision to Diff 467856.Oct 14 2022, 11:22 AM

switched to function, instead of operator.

ymandel marked an inline comment as done.Oct 14 2022, 11:24 AM

Reviewers: I'm inclined towards a method vs overloaded operator. Please let me know.

I don't have a strong preference. But in case we come up with multiple kinds of equalities (see my comment about the properties) methods might work better.

Agreed. I switched to a free function. I think operator== just implies too much.

clang/lib/Analysis/FlowSensitive/Value.cpp
38

Good point. This only occurred to me once I was writing it as an operator==. But, we don't do this in the current code and I think its premature. I've taken it out and updated the comment to reflect. We will need to consider this for the future.

xazax.hun accepted this revision.Oct 14 2022, 11:31 AM
sgatev accepted this revision.Oct 17 2022, 3:22 AM
sgatev added inline comments.
clang/lib/Analysis/FlowSensitive/Value.cpp
16

This seems unnecessary.

clang/unittests/Analysis/FlowSensitive/ValueTest.cpp
31

I suggest dropping the symmetry comment.

ymandel updated this revision to Diff 468884.Oct 19 2022, 5:44 AM
ymandel marked an inline comment as done.

address comments

This revision was landed with ongoing or failed builds.Oct 19 2022, 5:44 AM
This revision was automatically updated to reflect the committed changes.