diff options
| author | Jannis Christopher Köhl <mail@koehl.dev> | 2022-09-04 12:29:19 +0200 |
|---|---|---|
| committer | Jannis Christopher Köhl <mail@koehl.dev> | 2022-11-07 10:35:15 +0100 |
| commit | 1e5ca5701496a73d822b8dff220c7a8e8463724b (patch) | |
| tree | c1cb4b8dd1aa36f722848dd5604b8e66041bfc74 | |
| parent | 904adcac0f93db6970fb1ee5164328b08cc926dd (diff) | |
| download | rust-1e5ca5701496a73d822b8dff220c7a8e8463724b.tar.gz rust-1e5ca5701496a73d822b8dff220c7a8e8463724b.zip | |
Use StorageDead and Deinit to flood place
| -rw-r--r-- | compiler/rustc_mir_dataflow/src/value_analysis.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 763ccff25a9..f625f71ccda 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -87,12 +87,16 @@ pub trait ValueAnalysis<'tcx> { StatementKind::CopyNonOverlapping(..) => { // FIXME: What to do here? } - StatementKind::StorageLive(..) - | StatementKind::StorageDead(..) - | StatementKind::Deinit(_) => { - // Could perhaps use these. + StatementKind::StorageDead(local) => { + // It is UB to access an unallocated local. + state.flood(Place::from(*local).as_ref(), self.map()); + } + StatementKind::Deinit(box place) => { + // It is UB to access `uninit` bytes. + state.flood(place.as_ref(), self.map()); } StatementKind::Nop + | StatementKind::StorageLive(..) | StatementKind::Retag(..) | StatementKind::FakeRead(..) | StatementKind::Coverage(..) |
