This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Do not crash on missing `Value` for struct-typed variable init.
ClosedPublic

Authored by ymandel on Apr 18 2022, 2:40 PM.

Details

Summary

Remove constraint that an initializing expression of struct type must have an
associated Value. This invariant is not and will not be guaranteed by the
framework, because of potentially uninitialized fields.

Diff Detail

Event Timeline

ymandel created this revision.Apr 18 2022, 2:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2022, 2:40 PM
ymandel requested review of this revision.Apr 18 2022, 2:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2022, 2:40 PM
sgatev added inline comments.Apr 19 2022, 4:10 AM
clang/lib/Analysis/FlowSensitive/Transfer.cpp
184–186

The patch makes sense to me in the current state, but it's unclear why is this not something that we'd like to do in the long term.

ymandel added inline comments.Apr 19 2022, 6:21 AM
clang/lib/Analysis/FlowSensitive/Transfer.cpp
184–186

Because of uninterpreted fields. If we consider those a temporary fix, then I agree about the long term. I'd thought those were here to stay. That said, if we find a way to either interperet fields lazily or only interpret those needed in the current function scope, we may be able to avoid uninterpreted expressions.

This also begs the question as to why we insist on initializing the variable. Arguably, if the expresssion is uninterpreted, so should be the variable. So, we should at least explain why we're distinguishing. Thoughts on my adding a comment to that effect?

xazax.hun accepted this revision.Apr 19 2022, 9:02 AM
xazax.hun added inline comments.
clang/lib/Analysis/FlowSensitive/Transfer.cpp
184–186

Because of uninterpreted fields.

Could you elaborate on this? Do you mean fields being uninterpreted due to hitting a depth limit or being recursive? Or is this something else?

This revision is now accepted and ready to land.Apr 19 2022, 9:02 AM
sgatev accepted this revision.Apr 19 2022, 9:21 AM
sgatev added inline comments.
clang/lib/Analysis/FlowSensitive/Transfer.cpp
184–186

Not initializing the variable in such cases also makes sense to me. I'd very much appreciate a comment. I suggest also keeping the FIXME as interpreting fields lazily (and thus relying that all fields that are accessed are initialized) is still an option.

ymandel updated this revision to Diff 423724.Apr 19 2022, 1:37 PM

extended comments.

This revision was landed with ongoing or failed builds.Apr 19 2022, 1:53 PM
This revision was automatically updated to reflect the committed changes.