This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Initialize fields of anonymous records correctly.
ClosedPublic

Authored by mboehme on Jun 27 2023, 3:09 AM.

Details

Summary

Previously, the newly added test would crash.

Depends On D153851

Diff Detail

Event Timeline

mboehme created this revision.Jun 27 2023, 3:09 AM
Herald added a project: Restricted Project. · View Herald Transcript
mboehme requested review of this revision.Jun 27 2023, 3:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2023, 3:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
mboehme added inline comments.
clang/lib/Analysis/FlowSensitive/Transfer.cpp
575

It turns out this was doing strictly too much work.

CXXDefaultInitExpr should only be producing the default value. The actual initialization should be left to CXXCtorInitializer.

mboehme updated this revision to Diff 535284.Jun 28 2023, 1:37 AM

Ensure we model a field of an anonymous record even if the only place it's used
is in an initializer.

Pre-merge failure looks unrelated

gribozavr2 accepted this revision.Jun 28 2023, 5:21 AM
gribozavr2 added inline comments.
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
390

Is there a chance that there will be no such child if we hit one of our limits for modeling recursive data structures?

This revision is now accepted and ready to land.Jun 28 2023, 5:21 AM
mboehme marked an inline comment as done.Jun 28 2023, 6:18 AM
mboehme added inline comments.
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
390

Happily, this isn't a concern. AggregateStorageLocations always contain the same set of fields (the ones that are "modeled", i.e. accessed in some way). And this is a nice invariant to have.

Where we do the cutoff for modeling recursive data structures is that the storage location returned by getChild() may not have a Value associated with it.

This revision was landed with ongoing or failed builds.Jun 28 2023, 9:07 PM
This revision was automatically updated to reflect the committed changes.
mboehme marked an inline comment as done.