This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Fix handling of `DeclRefExpr`s to `BindingDecl`s.
ClosedPublic

Authored by ymandel on Jan 3 2023, 7:48 AM.

Details

Summary

The invariants around ReferenceValues are subtle (arguably, too much so). That
includes that we need to take care not to double wrap them -- in cases where we
wrap a loc in an ReferenceValue we need to be sure that the pointee isn't
already a ReferenceValue. BindingDecl introduces another situation in which
this can arise. Previously, the code did not properly handle BindingDecl,
resulting in double-wrapped values, which broke other invariants (at least, that
struct values have an AggregateStorageLocation).

This patch adjusts the interpretation of DeclRefExpr to take BindingDecl's
peculiarities into account. It also fixes the two tests which should have caught
this issue but were themselves (subtly) buggy.

Diff Detail

Event Timeline

ymandel created this revision.Jan 3 2023, 7:48 AM
Herald added a project: Restricted Project. · View Herald Transcript
ymandel requested review of this revision.Jan 3 2023, 7:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2023, 7:48 AM
ymandel updated this revision to Diff 486250.Jan 4 2023, 5:56 AM

add clarifying comment regarding interpration of DecompositionDecl.

ymandel updated this revision to Diff 493646.Jan 31 2023, 9:18 AM

Rebase onto HEAD

xazax.hun accepted this revision.Jan 31 2023, 3:16 PM

I hope we will be able to get rid of this SkipPast thing at some point by looking at the value categories of the AST instead.

This revision is now accepted and ready to land.Jan 31 2023, 3:16 PM

I hope we will be able to get rid of this SkipPast thing at some point by looking at the value categories of the AST instead.

Thanks! Agreed: filed issue #60444.

This revision was landed with ongoing or failed builds.Feb 1 2023, 5:23 AM
This revision was automatically updated to reflect the committed changes.