This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Enable comparison of distinct values in Environment
ClosedPublic

Authored by sgatev on Jan 31 2022, 4:24 AM.

Details

Summary

Make specializations of DataflowAnalysis extendable with domain-specific
logic for comparing distinct values when comparing environments.

This includes a breaking change to the runDataflowAnalysis interface
as the return type is now llvm::Expected<...>.

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Diff Detail

Event Timeline

sgatev created this revision.Jan 31 2022, 4:24 AM
sgatev requested review of this revision.Jan 31 2022, 4:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 31 2022, 4:24 AM
sgatev updated this revision to Diff 404743.Jan 31 2022, 2:50 PM

Reformat code.

ymandel accepted this revision.Jan 31 2022, 5:48 PM

Please mention the (breaking) API changes to runDataflowAnalysis, etc. in the patch description.

This revision is now accepted and ready to land.Jan 31 2022, 5:48 PM
xazax.hun added inline comments.Jan 31 2022, 10:36 PM
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
155–156

Now we have multiple, slightly different versions of equality for values. One here, one in Environment::equivalentTo. I'd prefer to have one way to check value equality factored out somewhere and reused it both here and there. Also, Environment::equivalentTo works with any indirection, this snippet only works with pointers (and not with references).

It is also not clear to me at this point what is the role of compareEquivalent. Is it intentional that it is not used here?

sgatev updated this revision to Diff 404886.Feb 1 2022, 4:46 AM
sgatev marked an inline comment as done.

Address reviewers' comments.

sgatev updated this revision to Diff 404888.Feb 1 2022, 4:52 AM

Update comment.

sgatev edited the summary of this revision. (Show Details)Feb 1 2022, 4:52 AM
sgatev added a comment.Feb 1 2022, 4:54 AM

Mentioned the breaking interface change in the description.

clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
155–156

Good point, I updated the code. Please take a look.

sgatev updated this revision to Diff 404890.Feb 1 2022, 4:57 AM

Update comment.

xazax.hun accepted this revision.Feb 1 2022, 4:58 AM

Thanks, this looks much better!

ymandel added inline comments.Feb 1 2022, 5:23 AM
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
56

I really like this new name/API. Much clearer concept.

64

What does this comment mean, now that there's no environment? Could we say something specific to the values themselves?

sgatev updated this revision to Diff 404923.Feb 1 2022, 7:08 AM
sgatev marked an inline comment as done.

Address reviewers' comments.

clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
64

Updated the comment and added a FIXME to consider removing the type argument.

This revision was landed with ongoing or failed builds.Feb 1 2022, 7:27 AM
This revision was automatically updated to reflect the committed changes.