about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJannis Christopher Köhl <mail@koehl.dev>2022-09-04 12:29:19 +0200
committerJannis Christopher Köhl <mail@koehl.dev>2022-11-07 10:35:15 +0100
commit1e5ca5701496a73d822b8dff220c7a8e8463724b (patch)
treec1cb4b8dd1aa36f722848dd5604b8e66041bfc74
parent904adcac0f93db6970fb1ee5164328b08cc926dd (diff)
downloadrust-1e5ca5701496a73d822b8dff220c7a8e8463724b.tar.gz
rust-1e5ca5701496a73d822b8dff220c7a8e8463724b.zip
Use StorageDead and Deinit to flood place
-rw-r--r--compiler/rustc_mir_dataflow/src/value_analysis.rs12
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(..)