Handle StorageLive

This commit is contained in:
Jannis Christopher Köhl 2022-09-09 11:56:10 +02:00
parent e2ddf8a6e5
commit 817c27744d

View File

@ -83,20 +83,21 @@ pub trait ValueAnalysis<'tcx> {
} }
StatementKind::SetDiscriminant { .. } => { StatementKind::SetDiscriminant { .. } => {
// Could treat this as writing a constant to a pseudo-place. // Could treat this as writing a constant to a pseudo-place.
// But discriminants are currently not tracked, so we do nothing.
// Related: https://github.com/rust-lang/unsafe-code-guidelines/issues/84
} }
StatementKind::CopyNonOverlapping(..) => { StatementKind::CopyNonOverlapping(..) => {
// FIXME: What to do here? // FIXME: What to do here?
} }
StatementKind::StorageDead(local) => { StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
// It is UB to access an unallocated local. // It is UB to read from an unitialized or unallocated local.
state.flood(Place::from(*local).as_ref(), self.map()); state.flood(Place::from(*local).as_ref(), self.map());
} }
StatementKind::Deinit(box place) => { StatementKind::Deinit(box place) => {
// It is UB to access `uninit` bytes. // It is UB to read `uninit` bytes.
state.flood(place.as_ref(), self.map()); state.flood(place.as_ref(), self.map());
} }
StatementKind::Nop StatementKind::Nop
| StatementKind::StorageLive(..)
| StatementKind::Retag(..) | StatementKind::Retag(..)
| StatementKind::FakeRead(..) | StatementKind::FakeRead(..)
| StatementKind::Coverage(..) | StatementKind::Coverage(..)