This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Add transfer functions for constructors
ClosedPublic

Authored by sgatev on Jan 13 2022, 5:56 AM.

Details

Summary

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 13 2022, 5:56 AM
sgatev requested review of this revision.Jan 13 2022, 5:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2022, 5:56 AM
xazax.hun accepted this revision.Jan 13 2022, 9:06 AM
xazax.hun added inline comments.
clang/lib/Analysis/FlowSensitive/Transfer.cpp
115

An alternative way to handle Noop operations would be to make location lookup function always skip certain nodes, so we do not need to store locations for those subexpressions. I don't have a strong feeling for either solution, this is fine as it is, just wanted to be sure that both were considered.

287

Interesting, I only see isCallToStdMove in the CallExpr API, although I imagine, std::forward has a similar level of importance.

clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
40

Shouldn't we piggyback on clang::LangStandard::Kind? If it is not easy to convert that to the appropriate command line flag feel free to ignore this.

This revision is now accepted and ready to land.Jan 13 2022, 9:06 AM
sgatev updated this revision to Diff 399707.Jan 13 2022, 9:52 AM
sgatev marked 2 inline comments as done.

Address reviewers' comments.

sgatev marked an inline comment as done.Jan 13 2022, 9:54 AM
sgatev added inline comments.
clang/lib/Analysis/FlowSensitive/Transfer.cpp
115

It makes sense to consider it. Right now I don't have signals that one is better than the other. I think the current implementation fits the general model a bit better. Nevertheless, I added a FIXME to keep this option in mind.

287

I haven't looked into std::forward yet, but happy to do that in the next patch.

clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
40

Makes sense. Thanks for pointing this out!

xazax.hun added inline comments.Jan 13 2022, 10:11 AM
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
1362

I think this changed from 14 to 17 in the last revision. Is this intentional?

sgatev updated this revision to Diff 399714.Jan 13 2022, 10:14 AM
sgatev marked 2 inline comments as done.

Address reviewers' comments.

clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
1362

Not intentional. Thanks for catching it!

ymandel accepted this revision.Jan 14 2022, 5:46 AM
ymandel added inline comments.
clang/lib/Analysis/FlowSensitive/Transfer.cpp
99–106

use a switch?

sgatev updated this revision to Diff 399968.Jan 14 2022, 6:18 AM
sgatev marked an inline comment as done.

Address reviewers' comments.

sgatev added inline comments.Jan 14 2022, 6:25 AM
clang/lib/Analysis/FlowSensitive/Transfer.cpp
99–106

Refactored to use a switch.

This revision was automatically updated to reflect the committed changes.