This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow][NFC] Eliminate StmtToEnvMap interface.
ClosedPublic

Authored by mboehme on Mar 21 2023, 2:14 AM.

Details

Summary

Instead, we turn StmtToEnvMap into a concrete class with the implementation that used to live in StmtToEnvMapImpl.

The layering issue that originally required the indirection through the
StmtToEnvMap interface no longer exists.

Diff Detail

Event Timeline

mboehme created this revision.Mar 21 2023, 2:14 AM
Herald added a project: Restricted Project. · View Herald Transcript
mboehme requested review of this revision.Mar 21 2023, 2:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2023, 2:14 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
gribozavr2 accepted this revision.Mar 21 2023, 4:29 AM
gribozavr2 added a subscriber: gribozavr2.
gribozavr2 added inline comments.
clang/include/clang/Analysis/FlowSensitive/Transfer.h
29–31

Could you move the comment to the new declaration of this function?

This revision is now accepted and ready to land.Mar 21 2023, 4:29 AM
mboehme updated this revision to Diff 506913.Mar 21 2023, 4:38 AM

Add back comment that I inadvertently deleted.

mboehme added inline comments.Mar 21 2023, 4:41 AM
clang/include/clang/Analysis/FlowSensitive/Transfer.h
29–31

Oops, done. Thanks for catching!

clang/lib/Analysis/FlowSensitive/Transfer.cpp
144

I'm not changing the return type of getEnvironment() to a reference because https://reviews.llvm.org/D146514 (in review) makes a change that will cause getEnvironment() to return nullptr if S is not reachable, and I want to avoid churn on the return type. (There will be a conflict between the two changes anyway, and I'll deal with that once the first of the changes has landed.)

xazax.hun accepted this revision.Mar 21 2023, 9:03 AM

After some offline discussion with reviewers, we've come to the conclusion that AnalysisContext isn't a sufficiently clear abstraction to warrant putting it in a header.

For the time being, I'll therefore pursue the less ambitious approach of simply eliminating the StmtToEnvMap interface and instead turning it into a concrete class with the implementation that used to be in StmtToEnvMapImpl.

mboehme updated this revision to Diff 507297.Mar 22 2023, 3:14 AM

Pursue a less ambitious approach, as described in the previous comment.

@gribozavr2 @xazax.hun Just wanted to confirm that you still regard this as ready to land now that I've changed the patch as we discussed offline?

mboehme edited the summary of this revision. (Show Details)Mar 22 2023, 3:20 AM
gribozavr2 accepted this revision.Mar 22 2023, 6:01 AM
gribozavr2 added inline comments.
clang/include/clang/Analysis/FlowSensitive/Transfer.h
35

Drop virtual?

ymandel accepted this revision.Mar 22 2023, 6:23 AM

thanks!

clang/include/clang/Analysis/FlowSensitive/Transfer.h
36–40

Nit: why inline vs putting the definition in Transfer.cpp? I don't have a good sense for the size cutoff on this decision but if it's only used there, then might make sense just to keep the header leaner.

xazax.hun accepted this revision.Mar 22 2023, 8:03 AM

Thanks!

mboehme updated this revision to Diff 508907.Mar 28 2023, 12:28 AM

Rebase to head

mboehme updated this revision to Diff 508916.Mar 28 2023, 12:56 AM

Changes in response to review comments

mboehme marked 2 inline comments as done.Mar 28 2023, 12:57 AM
mboehme added inline comments.
clang/include/clang/Analysis/FlowSensitive/Transfer.h
35

Duh. Thanks for catching. Done!

36–40

Good point. Done.

This revision was landed with ongoing or failed builds.Mar 28 2023, 1:06 AM
This revision was automatically updated to reflect the committed changes.
mboehme marked 2 inline comments as done.