Add missing types to minimum dependency checking

This commit is contained in:
gingerBill
2019-01-05 11:15:23 +00:00
parent 3a18ae3978
commit 9156af2bab
2 changed files with 37 additions and 3 deletions
+29 -1
View File
@@ -1143,6 +1143,8 @@ void add_type_info_type(CheckerContext *c, Type *t) {
add_type_info_type(c, bt);
switch (bt->kind) {
case Type_Invalid:
break;
case Type_Basic:
switch (bt->Basic.kind) {
case Basic_string:
@@ -1194,6 +1196,7 @@ void add_type_info_type(CheckerContext *c, Type *t) {
case Type_BitSet:
add_type_info_type(c, bt->BitSet.elem);
add_type_info_type(c, bt->BitSet.underlying);
break;
case Type_Opaque:
@@ -1239,6 +1242,10 @@ void add_type_info_type(CheckerContext *c, Type *t) {
add_type_info_type(c, bt->Proc.params);
add_type_info_type(c, bt->Proc.results);
break;
default:
GB_PANIC("Unhandled type: %*.s", LIT(type_strings[bt->kind]));
break;
}
}
@@ -1304,6 +1311,8 @@ void add_min_dep_type_info(Checker *c, Type *t) {
add_min_dep_type_info(c, bt);
switch (bt->kind) {
case Type_Invalid:
break;
case Type_Basic:
switch (bt->Basic.kind) {
case Basic_string:
@@ -1311,8 +1320,8 @@ void add_min_dep_type_info(Checker *c, Type *t) {
add_min_dep_type_info(c, t_int);
break;
case Basic_any:
add_min_dep_type_info(c, t_type_info_ptr);
add_min_dep_type_info(c, t_rawptr);
add_min_dep_type_info(c, t_typeid);
break;
case Basic_complex64:
@@ -1326,6 +1335,15 @@ void add_min_dep_type_info(Checker *c, Type *t) {
}
break;
case Type_Opaque:
add_min_dep_type_info(c, bt->Opaque.elem);
break;
case Type_BitSet:
add_min_dep_type_info(c, bt->BitSet.elem);
add_min_dep_type_info(c, bt->BitSet.underlying);
break;
case Type_Pointer:
add_min_dep_type_info(c, bt->Pointer.elem);
break;
@@ -1390,6 +1408,10 @@ void add_min_dep_type_info(Checker *c, Type *t) {
add_min_dep_type_info(c, bt->Proc.params);
add_min_dep_type_info(c, bt->Proc.results);
break;
default:
GB_PANIC("Unhandled type: %*.s", LIT(type_strings[bt->kind]));
break;
}
}
@@ -3518,6 +3540,12 @@ void check_parsed_files(Checker *c) {
TIME_SECTION("generate minimum dependency set");
generate_minimum_dependency_set(c, c->info.entry_point);
for_array(i, c->info.minimum_dependency_set.entries) {
Entity *e = c->info.minimum_dependency_set.entries[i].ptr;
if (is_type_bit_set(e->type)) {
gb_printf("%.*s\n", LIT(e->token.string));
}
}
TIME_SECTION("calculate global init order");
+8 -2
View File
@@ -4567,6 +4567,12 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
if (is_type_u8_ptr(src) && is_type_cstring(dst)) {
return ir_emit_bitcast(proc, value, dst);
}
if (is_type_cstring(src) && is_type_rawptr(dst)) {
return ir_emit_bitcast(proc, value, dst);
}
if (is_type_rawptr(src) && is_type_cstring(dst)) {
return ir_emit_bitcast(proc, value, dst);
}
if (are_types_identical(src, t_cstring) && are_types_identical(dst, t_string)) {
irValue *c = ir_emit_conv(proc, value, t_cstring);
@@ -4842,7 +4848,7 @@ irValue *ir_emit_transmute(irProcedure *proc, irValue *value, Type *t) {
if (is_type_integer(src) && (is_type_pointer(dst) || is_type_cstring(dst))) {
Type *vt = core_type(ir_type(value));
return ir_emit(proc, ir_instr_conv(proc, irConv_inttoptr, value, vt, t));
}else if ((is_type_pointer(src) || is_type_cstring(src)) && is_type_integer(dst)) {
} else if ((is_type_pointer(src) || is_type_cstring(src)) && is_type_integer(dst)) {
Type *vt = core_type(ir_type(value));
return ir_emit(proc, ir_instr_conv(proc, irConv_ptrtoint, value, vt, t));
}
@@ -5014,7 +5020,7 @@ isize ir_type_info_index(CheckerInfo *info, Type *type, bool err_on_not_found=tr
}
}
if (err_on_not_found) {
GB_PANIC("NOT FOUND ir_type_info_index %s", type_to_string(type));
GB_PANIC("NOT FOUND ir_type_info_index %s @ index %td", type_to_string(type), index);
}
return -1;
}