File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
compiler/rustc_middle/src/mir/interpret/allocation
src/tools/miri/src/shims/native_lib Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,17 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
120
120
}
121
121
}
122
122
123
+ /// Gets the provenances of all bytes (including from pointers) in a range.
124
+ pub fn get_range (
125
+ & self ,
126
+ cx : & impl HasDataLayout ,
127
+ range : AllocRange ,
128
+ ) -> impl Iterator < Item = Prov > {
129
+ let ptr_provs = self . range_ptrs_get ( range, cx) . iter ( ) . map ( |( _, p) | * p) ;
130
+ let byte_provs = self . range_bytes_get ( range) . iter ( ) . map ( |( _, ( p, _) ) | * p) ;
131
+ ptr_provs. chain ( byte_provs)
132
+ }
133
+
123
134
/// Attempt to merge per-byte provenance back into ptr chunks, if the right fragments
124
135
/// sit next to each other. Return `false` is that is not possible due to partial pointers.
125
136
pub fn merge_bytes ( & mut self , cx : & impl HasDataLayout ) -> bool {
Original file line number Diff line number Diff line change @@ -242,14 +242,9 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
242
242
243
243
match evt {
244
244
AccessEvent :: Read ( _) => {
245
- // FIXME: ProvenanceMap should have something like get_range().
246
- let p_map = alloc. provenance ( ) ;
247
- for idx in overlap {
248
- // If a provenance was read by the foreign code, expose it.
249
- if let Some ( ( prov, _idx) ) = p_map. get_byte ( Size :: from_bytes ( idx) , this)
250
- {
251
- this. expose_provenance ( prov) ?;
252
- }
245
+ // If a provenance was read by the foreign code, expose it.
246
+ for prov in alloc. provenance ( ) . get_range ( this, overlap. into ( ) ) {
247
+ this. expose_provenance ( prov) ?;
253
248
}
254
249
}
255
250
AccessEvent :: Write ( _, certain) => {
You can’t perform that action at this time.
0 commit comments