This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Use `Strict` accessors where we weren't using them yet.
ClosedPublic

Authored by mboehme on Jul 31 2023, 4:54 AM.

Details

Summary

This eliminates all uses of the deprecated accessors.

Diff Detail

Event Timeline

mboehme created this revision.Jul 31 2023, 4:54 AM
Herald added a project: Restricted Project. · View Herald Transcript
mboehme requested review of this revision.Jul 31 2023, 4:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2023, 4:54 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ymandel accepted this revision.Jul 31 2023, 5:24 AM
ymandel added inline comments.
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
542

loc == nullptr

545

Should this line instead be outside of this if? So that the flow is

Loc = get
if (!Loc) Loc = create
set(Loc)
clang/lib/Analysis/FlowSensitive/Transfer.cpp
473–476

What happens otherwise? I gather that S just isn't associated with anything?

This revision is now accepted and ready to land.Jul 31 2023, 5:24 AM
mboehme updated this revision to Diff 545611.Jul 31 2023, 5:36 AM

Use Loc == nullptr instead of !Loc.

mboehme marked 2 inline comments as done.Jul 31 2023, 5:40 AM
mboehme added inline comments.
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
545

I don't understand -- wouldn't this just be doing unnecessary work?

If

Loc = cast_or_null<AggregateStorageLocation>(
        State.Env.getStorageLocationStrict(*E));

returns a non-null Loc, we don't create a new Loc, hence

State.Env.setStorageLocationStrict(*E, *Loc);

is a no-op, as E is already associated with Loc.

clang/lib/Analysis/FlowSensitive/Transfer.cpp
473–476

Correct. The idea being that if S is elidable, i.e. just a pass-through, we want to pass through any StructValue that we got, and so if we didn't get a StructValue, then we shouldn't pass one through.

I guess we could also just create a StructValue from scratch and associate it with ArgLoc, but I'm not sure that it makes much of a difference in practice.

ymandel accepted this revision.Jul 31 2023, 7:23 AM

SGTM

clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
545

Right, I was not paying enough attention. I was thinking specifically about the value. basically, i confused line 545 for line 549.

xazax.hun accepted this revision.Jul 31 2023, 8:09 AM
This revision was automatically updated to reflect the committed changes.
mboehme marked an inline comment as done.