Lines Matching refs:type

33 	if (!type_is_ptr(sval.type))  in is_err_ptr()
81 sval_to_str(sval_type_max(prev_drange->min.type))); in show_rl()
108 static int sval_too_big(struct symbol *type, sval_t sval) in sval_too_big() argument
110 if (type_bits(type) >= 32 && in sval_too_big()
111 type_bits(sval.type) <= type_bits(type)) in sval_too_big()
113 if (sval.uvalue <= ((1ULL << type_bits(type)) - 1)) in sval_too_big()
115 if (type_signed(sval.type)) { in sval_too_big()
116 if (type_unsigned(type)) { in sval_too_big()
118 if (neg <= sval_type_max(type).uvalue) in sval_too_big()
121 if (sval.value < sval_type_min(type).value) in sval_too_big()
123 if (sval.value > sval_type_max(type).value) in sval_too_big()
127 if (sval.uvalue > sval_type_max(type).uvalue) in sval_too_big()
132 static int truncates_nicely(struct symbol *type, sval_t min, sval_t max) in truncates_nicely() argument
135 int bits = type_bits(type); in truncates_nicely()
137 if (type_is_fp(min.type) && !type_is_fp(type)) in truncates_nicely()
140 if (bits >= type_bits(min.type)) in truncates_nicely()
147 static void add_range_t(struct symbol *type, struct range_list **rl, sval_t min, sval_t max) in add_range_t() argument
151 add_range(rl, sval_cast(type, min), sval_cast(type, max)); in add_range_t()
156 if (sval_fits(type, min) && sval_fits(type, max)) { in add_range_t()
157 add_range(rl, sval_cast(type, min), sval_cast(type, max)); in add_range_t()
161 if (truncates_nicely(type, min, max)) { in add_range_t()
162 add_range(rl, sval_cast(type, min), sval_cast(type, max)); in add_range_t()
172 if (sval_too_big(type, min) || sval_too_big(type, max)) { in add_range_t()
173 add_range(rl, sval_type_min(type), sval_type_max(type)); in add_range_t()
178 if (sval_is_negative(min) && type_unsigned(type)) { in add_range_t()
180 if (sval_too_high(type, max)) { in add_range_t()
181 add_range(rl, sval_type_min(type), sval_type_max(type)); in add_range_t()
184 add_range(rl, sval_type_val(type, 0), sval_cast(type, max)); in add_range_t()
185 max = sval_type_max(type); in add_range_t()
187 max = sval_cast(type, max); in add_range_t()
189 min = sval_cast(type, min); in add_range_t()
194 if (sval_unsigned(max) && sval_is_negative(sval_cast(type, max))) { in add_range_t()
195 if (!sval_is_negative(sval_cast(type, min))) { in add_range_t()
196 add_range(rl, sval_cast(type, min), sval_type_max(type)); in add_range_t()
197 min = sval_type_min(type); in add_range_t()
199 min = sval_cast(type, min); in add_range_t()
201 max = sval_cast(type, max); in add_range_t()
205 add_range(rl, sval_cast(type, min), sval_cast(type, max)); in add_range_t()
300 static int get_val_from_key(int use_max, struct symbol *type, const char *c, struct expression *cal… in get_val_from_key() argument
307 ret = sval_type_max(type); in get_val_from_key()
309 ret = sval_type_min(type); in get_val_from_key()
405 struct symbol *type; in filter_by_comparison_call() local
411 if (!call || call->type != EXPR_CALL) in filter_by_comparison_call()
420 type = &int_ctype; in filter_by_comparison_call()
421 if (type_positive_bits(rl_type(start_rl)) > type_positive_bits(type)) in filter_by_comparison_call()
422 type = rl_type(start_rl); in filter_by_comparison_call()
423 if (type_positive_bits(rl_type(right_orig)) > type_positive_bits(type)) in filter_by_comparison_call()
424 type = rl_type(right_orig); in filter_by_comparison_call()
426 casted_start = cast_rl(type, start_rl); in filter_by_comparison_call()
427 right_orig = cast_rl(type, right_orig); in filter_by_comparison_call()
433 static sval_t parse_val(int use_max, struct expression *call, struct symbol *type, const char *c, c… in parse_val() argument
438 if (type == &float_ctype) in parse_val()
439 return sval_type_fval(type, strtof(start, (char **)endp)); in parse_val()
440 else if (type == &double_ctype) in parse_val()
441 return sval_type_fval(type, strtod(start, (char **)endp)); in parse_val()
442 else if (type == &ldouble_ctype) in parse_val()
443 return sval_type_fval(type, strtold(start, (char **)endp)); in parse_val()
446 ret = sval_type_max(type); in parse_val()
449 ret = sval_type_val(type, ULLONG_MAX); in parse_val()
452 ret = sval_type_val(type, LLONG_MAX); in parse_val()
455 ret = sval_type_val(type, UINT_MAX); in parse_val()
458 ret = sval_type_val(type, INT_MAX); in parse_val()
461 ret = sval_type_val(type, USHRT_MAX); in parse_val()
464 ret = sval_type_val(type, SHRT_MAX); in parse_val()
467 ret = sval_type_min(type); in parse_val()
470 ret = sval_type_val(type, LLONG_MIN); in parse_val()
473 ret = sval_type_val(type, INT_MIN); in parse_val()
476 ret = sval_type_val(type, SHRT_MIN); in parse_val()
479 ret = sval_type_val(type, LONG_MIN); in parse_val()
482 ret = sval_type_val(type, LONG_MAX); in parse_val()
485 ret = sval_type_val(type, ULONG_MAX); in parse_val()
488 ret = sval_type_val(type, valid_ptr_max); in parse_val()
492 get_val_from_key(1, type, start, call, &c, &ret); in parse_val()
493 } else if (type_positive_bits(type) == 64) { in parse_val()
494 ret = sval_type_val(type, strtoull(start, (char **)&c, 0)); in parse_val()
496 ret = sval_type_val(type, strtoll(start, (char **)&c, 0)); in parse_val()
533 static void str_to_rl_helper(struct expression *call, struct symbol *type, const char *str, const c… in str_to_rl_helper() argument
539 prev_min = sval_type_min(type); in str_to_rl_helper()
540 min = sval_type_min(type); in str_to_rl_helper()
541 max = sval_type_max(type); in str_to_rl_helper()
545 if (sval_cmp(min, sval_type_min(type)) != 0) in str_to_rl_helper()
547 max = sval_type_max(type); in str_to_rl_helper()
548 add_range_t(type, &rl_tmp, min, max); in str_to_rl_helper()
553 min = parse_val(0, call, type, c, &c); in str_to_rl_helper()
554 if (!sval_fits(type, min)) in str_to_rl_helper()
555 min = sval_type_min(type); in str_to_rl_helper()
560 add_range_t(type, &rl_tmp, min, min); in str_to_rl_helper()
564 add_range_t(type, &rl_tmp, min, min); in str_to_rl_helper()
570 max = sval_type_max(type); in str_to_rl_helper()
571 add_range_t(type, &rl_tmp, min, max); in str_to_rl_helper()
583 max = parse_val(1, call, type, c, &c); in str_to_rl_helper()
584 if (!sval_fits(type, max)) in str_to_rl_helper()
585 max = sval_type_max(type); in str_to_rl_helper()
587 max = sval_type_max(type); in str_to_rl_helper()
588 add_range_t(type, &rl_tmp, min, max); in str_to_rl_helper()
594 add_range_t(type, &rl_tmp, min, max); in str_to_rl_helper()
605 static void str_to_dinfo(struct expression *call, struct symbol *type, const char *value, struct da… in str_to_dinfo() argument
612 if (!type) in str_to_dinfo()
613 type = &llong_ctype; in str_to_dinfo()
629 str_to_rl_helper(call, type, value, &c, &rl); in str_to_dinfo()
655 rl = cast_rl(type, rl); in str_to_dinfo()
662 struct symbol *type; in rl_is_sane() local
664 type = rl_type(rl); in rl_is_sane()
666 if (!sval_fits(type, tmp->min)) in rl_is_sane()
668 if (!sval_fits(type, tmp->max)) in rl_is_sane()
677 void str_to_rl(struct symbol *type, char *value, struct range_list **rl) in str_to_rl() argument
681 str_to_dinfo(NULL, type, value, &dinfo); in str_to_rl()
683 dinfo.value_ranges = alloc_whole_rl(type); in str_to_rl()
687 void call_results_to_rl(struct expression *expr, struct symbol *type, const char *value, struct ran… in call_results_to_rl() argument
691 str_to_dinfo(strip_expr(expr), type, value, &dinfo); in call_results_to_rl()
750 ret.type = &llong_ctype; in rl_min()
763 ret.type = &llong_ctype; in rl_max()
790 return rl_min(rl).type; in rl_type()
821 return alloc_whole_rl(min.type); in alloc_rl()
827 struct range_list *alloc_whole_rl(struct symbol *type) in alloc_whole_rl() argument
829 if (!type || type_positive_bits(type) < 0) in alloc_whole_rl()
830 type = &llong_ctype; in alloc_whole_rl()
831 if (type->type == SYM_ARRAY) in alloc_whole_rl()
832 type = &ptr_ctype; in alloc_whole_rl()
834 return alloc_rl(sval_type_min(type), sval_type_max(type)); in alloc_whole_rl()
857 if (!type_is_ptr(min.type)) in collapse_pointer_rl()
907 if (*list && rl_type(*list) != min.type) { in add_range()
908 if (rl_type(*list)->type == SYM_PTR) { in add_range()
911 } else if (min.type->type == SYM_PTR) { in add_range()
912 *list = cast_rl(min.type, *list); in add_range()
913 } else if (type_bits(rl_type(*list)) >= type_bits(min.type)) { in add_range()
917 *list = cast_rl(min.type, *list); in add_range()
922 min = sval_type_min(min.type); in add_range()
923 max = sval_type_max(min.type); in add_range()
1236 struct symbol *type; in possibly_true() local
1245 type = rl_type(rl_left); in possibly_true()
1246 if (type_positive_bits(type) < type_positive_bits(rl_type(rl_right))) in possibly_true()
1247 type = rl_type(rl_right); in possibly_true()
1248 if (type_positive_bits(type) < 31) in possibly_true()
1249 type = &int_ctype; in possibly_true()
1251 rl_left = cast_rl(type, rl_left); in possibly_true()
1252 rl_right = cast_rl(type, rl_right); in possibly_true()
1267 struct symbol *type; in possibly_false() local
1274 type = rl_type(rl_left); in possibly_false()
1275 if (type_positive_bits(type) < type_positive_bits(rl_type(rl_right))) in possibly_false()
1276 type = rl_type(rl_right); in possibly_false()
1277 if (type_positive_bits(type) < 31) in possibly_false()
1278 type = &int_ctype; in possibly_false()
1280 rl_left = cast_rl(type, rl_left); in possibly_false()
1281 rl_right = cast_rl(type, rl_right); in possibly_false()
1295 struct symbol *type; in possibly_true_rl() local
1300 type = rl_type(left_ranges); in possibly_true_rl()
1301 if (type_positive_bits(type) < type_positive_bits(rl_type(right_ranges))) in possibly_true_rl()
1302 type = rl_type(right_ranges); in possibly_true_rl()
1303 if (type_positive_bits(type) < 31) in possibly_true_rl()
1304 type = &int_ctype; in possibly_true_rl()
1306 left_ranges = cast_rl(type, left_ranges); in possibly_true_rl()
1307 right_ranges = cast_rl(type, right_ranges); in possibly_true_rl()
1321 struct symbol *type; in possibly_false_rl() local
1326 type = rl_type(left_ranges); in possibly_false_rl()
1327 if (type_positive_bits(type) < type_positive_bits(rl_type(right_ranges))) in possibly_false_rl()
1328 type = rl_type(right_ranges); in possibly_false_rl()
1329 if (type_positive_bits(type) < 31) in possibly_false_rl()
1330 type = &int_ctype; in possibly_false_rl()
1332 left_ranges = cast_rl(type, left_ranges); in possibly_false_rl()
1333 right_ranges = cast_rl(type, right_ranges); in possibly_false_rl()
1409 struct range_list *rl_truncate_cast(struct symbol *type, struct range_list *rl) in rl_truncate_cast() argument
1418 if (!type || type == rl_type(rl)) in rl_truncate_cast()
1424 if (type_bits(type) < type_bits(rl_type(rl))) { in rl_truncate_cast()
1425 min.uvalue = tmp->min.uvalue & ((1ULL << type_bits(type)) - 1); in rl_truncate_cast()
1426 max.uvalue = tmp->max.uvalue & ((1ULL << type_bits(type)) - 1); in rl_truncate_cast()
1429 min = sval_cast(type, min); in rl_truncate_cast()
1430 max = sval_cast(type, max); in rl_truncate_cast()
1432 add_range_t(type, &ret, min, max); in rl_truncate_cast()
1438 int rl_fits_in_type(struct range_list *rl, struct symbol *type) in rl_fits_in_type() argument
1440 if (type_bits(rl_type(rl)) <= type_bits(type)) in rl_fits_in_type()
1442 if (sval_cmp(rl_max(rl), sval_type_max(type)) > 0) in rl_fits_in_type()
1445 sval_cmp(rl_min(rl), sval_type_min(type)) < 0) in rl_fits_in_type()
1453 struct symbol *type; in rl_type_consistent() local
1455 type = rl_type(rl); in rl_type_consistent()
1457 if (type != tmp->min.type || type != tmp->max.type) in rl_type_consistent()
1469 sval_t min = { .type = &bool_ctype }; in cast_to_bool()
1470 sval_t max = { .type = &bool_ctype }; in cast_to_bool()
1495 struct range_list *cast_rl(struct symbol *type, struct range_list *rl) in cast_rl() argument
1503 if (!type) in cast_rl()
1506 return alloc_whole_rl(type); in cast_rl()
1507 if (type == rl_type(rl) && rl_type_consistent(rl)) in cast_rl()
1510 if (type == &bool_ctype) in cast_rl()
1514 add_range_t(type, &ret, tmp->min, tmp->max); in cast_rl()
1518 return alloc_whole_rl(type); in cast_rl()
1776 struct symbol *type; in handle_sub_rl() local
1786 type = &int_ctype; in handle_sub_rl()
1787 if (type_positive_bits(rl_type(left_orig)) > type_positive_bits(type)) in handle_sub_rl()
1788 type = rl_type(left_orig); in handle_sub_rl()
1789 if (type_positive_bits(rl_type(right_orig)) > type_positive_bits(type)) in handle_sub_rl()
1790 type = rl_type(right_orig); in handle_sub_rl()
1792 left_rl = cast_rl(type, left_orig); in handle_sub_rl()
1793 right_rl = cast_rl(type, right_orig); in handle_sub_rl()
1796 min = sval_type_min(type); in handle_sub_rl()
1799 min_ll.type = &llong_ctype; in handle_sub_rl()
1801 max_ll.type = &llong_ctype; in handle_sub_rl()
1809 } else if (type_positive_bits(type) < 63 && in handle_sub_rl()
1817 return cast_rl(type, result); in handle_sub_rl()
1857 min.type = max.type = &ullong_ctype; in handle_OR_rl()
1885 sval_t ret = { .type = sval.type }; in sval_lowest_set_bit()
1926 sval_t zero = { .type = rl_type(left_orig), }; in handle_lshift()
1947 if (min.value == 0 || max.value > sval_type_max(max.type).uvalue >> shift.uvalue) in handle_lshift()