Flood with bottom for Deinit, StorageLive and StorageDead

This commit is contained in:
Jannis Christopher Köhl 2022-10-05 20:46:39 +02:00
parent eab77320e6
commit 2f66e9417f

View File

@ -91,12 +91,13 @@ pub trait ValueAnalysis<'tcx> {
self.handle_intrinsic(intrinsic, state); self.handle_intrinsic(intrinsic, state);
} }
StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => { StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
// It is UB to read from an unitialized or unallocated local. // We can flood with bottom here, because `StorageLive` makes the local
state.flood(Place::from(*local).as_ref(), self.map()); // uninitialized, and `StorageDead` makes it UB to access.
state.flood_with(Place::from(*local).as_ref(), self.map(), Self::Value::bottom());
} }
StatementKind::Deinit(box place) => { StatementKind::Deinit(box place) => {
// It is UB to read `uninit` bytes. // The bottom states denotes uninitialized values.
state.flood(place.as_ref(), self.map()); state.flood_with(place.as_ref(), self.map(), Self::Value::bottom());
} }
StatementKind::Nop StatementKind::Nop
| StatementKind::Retag(..) | StatementKind::Retag(..)