This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Make directly bounded LazyCompoundVal as lazily copied
ClosedPublic

Authored by steakhal on Oct 4 2022, 2:27 AM.

Details

Summary

Previously, LazyCompoundVal bindings to subregions referred by
LazyCopoundVals, were not marked as lazily copied.

This change returns LazyCompoundVals from getInterestingValues(),
so their regions can be marked as lazily copied in RemoveDeadBindingsWorker::VisitBinding().

Depends on D134947

Authored by: Tomasz Kamiński <tomasz.kamiński@sonarsource.com>

Diff Detail

Event Timeline

steakhal created this revision.Oct 4 2022, 2:27 AM
Herald added a project: Restricted Project. · View Herald Transcript
steakhal requested review of this revision.Oct 4 2022, 2:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 4 2022, 2:27 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
steakhal added inline comments.Oct 4 2022, 3:01 AM
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
2290

Here is the continue which previously prevented getInterestingValues() returning a list containing LazyCompoundVals. Now, we actually want them to be able to mark them as lazily copied as described in the summary.
I'm just highlighting this, as when I reviewed this change it did not immediately stand out.

martong added inline comments.Oct 17 2022, 7:49 AM
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
2290

Yes, I was looking for the change too :D

2843

Why can we remove this line?
If LCS->getRegion() returns a non-null unconditionally then please add an assert.

clang/test/Analysis/trivial-copy-struct.cpp
95–97

Good!

clang/lib/StaticAnalyzer/Core/RegionStore.cpp
2843

The interface of the LazyCompoundVal is already marked as returning non-null, and this is why we removed the if condition:

LLVM_ATTRIBUTE_RETURNS_NONNULL
const TypedValueRegion *getRegion() const;
martong accepted this revision.Oct 18 2022, 6:13 AM

LGTM

clang/lib/StaticAnalyzer/Core/RegionStore.cpp
2843

Ok.

This revision is now accepted and ready to land.Oct 18 2022, 6:13 AM
steakhal marked 5 inline comments as done.Oct 18 2022, 9:43 AM

Thanks for the review @martong!
I'll land this tomorrow.