MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / is_obj_ptr_param

Function is_obj_ptr_param

crates/cranelift/src/debug/transform/attr.rs:317–346  ·  view source on GitHub ↗
(
    entry: &gimli::write::ConvertUnitEntry<Reader<'_>>,
    param_num: isize,
)

Source from the content-addressed store, hash-verified

315}
316
317fn is_obj_ptr_param(
318 entry: &gimli::write::ConvertUnitEntry<Reader<'_>>,
319 param_num: isize,
320) -> Result<bool, Error> {
321 debug_assert_eq!(entry.tag, gimli::DW_TAG_formal_parameter);
322 let unit = entry.read_unit;
323
324 // This logic was taken loosely from LLDB. It is known
325 // that it is not fully correct (doesn't handle 'deduced
326 // this', for example).
327 // Q: DWARF includes DW_AT_object_pointer as we use it,
328 // why do we need this heuristic as well?
329 // A: Declarations do not include DW_AT_object_pointer.
330 if param_num == 0
331 && entry.attr_value(gimli::DW_AT_artificial) == Some(AttributeValue::Flag(true))
332 {
333 // Either this has no name (declarations omit them), or its explicitly "this".
334 let name = entry.attr_value(gimli::DW_AT_name);
335 if name.is_none() || unit.attr_string(name.unwrap())?.slice().eq(b"this") {
336 // Finally, a type check. We expect a pointer.
337 if let Some(type_attr) = entry.attr_value(gimli::DW_AT_type) {
338 if let Some(type_die) = resolve_die_ref(unit, &type_attr)? {
339 return Ok(type_die.tag == gimli::DW_TAG_pointer_type);
340 }
341 }
342 }
343 };
344
345 return Ok(false);
346}

Callers 1

prepare_die_contextFunction · 0.85

Calls 7

resolve_die_refFunction · 0.85
OkFunction · 0.85
FlagClass · 0.50
is_noneMethod · 0.45
eqMethod · 0.45
sliceMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected