authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-04 01:56:21-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-04 01:56:21-05:00
log664b41af65d3c9bbc8e09ffcaa91d404fe87d7a0
treef7edd70f479394f6abbaff2a6736f4179ce940de
parentdbb1018ca678652423e237bb5465f9b20f88c986

fix debug information for function pointers in structs


2 files changed, 16 insertions(+), 2 deletions(-)

src/analyze.cpp+13-1
......@@ -1349,6 +1349,18 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
13491349
13501350 TypeTableEntry *field_type = type_struct_field->type_entry;
13511351
1352 // if the field is a function, actually the debug info should be a pointer.
1353 ZigLLVMDIType *field_di_type;
1354 if (field_type->id == TypeTableEntryIdFn) {
1355 TypeTableEntry *field_ptr_type = get_pointer_to_type(g, field_type, true);
1356 uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_ptr_type->type_ref);
1357 uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, field_ptr_type->type_ref);
1358 field_di_type = ZigLLVMCreateDebugPointerType(g->dbuilder, field_type->di_type,
1359 debug_size_in_bits, debug_align_in_bits, buf_ptr(&field_ptr_type->name));
1360 } else {
1361 field_di_type = field_type->di_type;
1362 }
1363
13521364 assert(field_type->type_ref);
13531365 assert(struct_type->type_ref);
13541366 assert(struct_type->data.structure.complete);
......@@ -1362,7 +1374,7 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
13621374 debug_size_in_bits,
13631375 debug_align_in_bits,
13641376 debug_offset_in_bits,
1365 0, field_type->di_type);
1377 0, field_di_type);
13661378
13671379 assert(di_element_types[gen_field_index]);
13681380 }
src/ir.cpp+3-1
......@@ -4925,7 +4925,9 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope,
49254925 name = buf_alloc();
49264926 buf_append_buf(name, &fn_entry->symbol_name);
49274927 buf_appendf(name, "(");
4928 // TODO render args
4928 // TODO render args. note that fn_type_id is likely not complete
4929 // at this time.
4930 // probably have to render them from the fn scope
49294931 buf_appendf(name, ")");
49304932 } else {
49314933 name = buf_sprintf("(anonymous %s at %s:%zu:%zu)", container_string(kind),