Skip to content

Commit 8f29018

Browse files
committed
add a Vtable kind of symbolic allocations
1 parent bca7b02 commit 8f29018

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/common.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
183183
}
184184
Scalar::Ptr(ptr, _size) => {
185185
let (alloc_id, offset) = ptr.into_parts();
186+
// For vtables, get the underlying data allocation.
187+
let alloc_id = match self.tcx.global_alloc(alloc_id) {
188+
GlobalAlloc::Vtable(ty, trait_ref) => {
189+
self.tcx.vtable_allocation((ty, trait_ref))
190+
}
191+
_ => alloc_id,
192+
};
186193
let base_addr =
187194
match self.tcx.global_alloc(alloc_id) {
188195
GlobalAlloc::Memory(alloc) => {
@@ -201,6 +208,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
201208
GlobalAlloc::Function(fn_instance) => {
202209
self.get_fn_addr(fn_instance)
203210
},
211+
GlobalAlloc::Vtable(..) => panic!("vtables are already handled"),
204212
GlobalAlloc::Static(def_id) => {
205213
assert!(self.tcx.is_static(def_id));
206214
self.get_static(def_id).get_address(None)

0 commit comments

Comments
 (0)