Skip to content

Commit 71fe191

Browse files
committed
CHB:TI: allow join of struct type and type of first field
1 parent 9b54f55 commit 71fe191

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

CodeHawk/CHB/bchlib/bCHFloc.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,14 @@ object (self)
13891389
(self#f#is_base_pointer v)
13901390
|| (TR.tfold_default is_pointer false (self#get_variable_type v))
13911391
) vars in
1392+
let _ =
1393+
log_diagnostics_result
1394+
~tag:"convert_addr_to_c_pointed_to_expr"
1395+
__FILE__ __LINE__
1396+
[(p2s self#l#toPretty);
1397+
"known pointers: ";
1398+
(p2s (pretty_print_list knownpointers
1399+
(fun v -> v#toPretty) "[" ", " "]"))] in
13921400
match knownpointers with
13931401
(* one known pointer, must be the base *)
13941402
| [base] when self#f#env#is_initial_stackpointer_value base ->

CodeHawk/CHB/bchlib/bCHTypeConstraintStore.ml

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -494,17 +494,42 @@ object (self)
494494
match result#singleton with
495495
| Some ixty -> Some (bcd#get_typ ixty)
496496
| _ ->
497-
begin
498-
log_evaluation ();
499-
log_diagnostics_result
500-
~tag:("top type constant in join for " ^ faddr)
501-
__FILE__ __LINE__
502-
[iaddr ^ " -- " ^ (register_to_string reg) ^ ": "
503-
^ (p2s (pretty_print_list
504-
(List.map bcd#get_typ result#toList)
505-
(fun ty -> STR (btype_to_string ty)) "[" "; " "]"))];
506-
None
507-
end
497+
match result#toList with
498+
| [ixty1; ixty2] ->
499+
(match (bcd#get_typ ixty1), (bcd#get_typ ixty2) with
500+
| TPtr (tty1, _), TPtr (tty2, _)
501+
when is_struct_type tty1 && is_scalar tty2 ->
502+
Some (bcd#get_typ ixty1)
503+
| TPtr (tty1, _), TPtr (tty2, _)
504+
when is_struct_type tty2 && is_scalar tty1 ->
505+
Some (bcd#get_typ ixty2)
506+
| _ ->
507+
begin
508+
log_evaluation ();
509+
log_diagnostics_result
510+
~tag:("top type constant in join for " ^ faddr)
511+
__FILE__ __LINE__
512+
[iaddr ^ " -- " ^ (register_to_string reg) ^ ": "
513+
^ (p2s (pretty_print_list
514+
(List.map bcd#get_typ result#toList)
515+
(fun ty -> STR (btype_to_string ty))
516+
"[" "; " "]"))];
517+
None
518+
end)
519+
| _ ->
520+
begin
521+
log_evaluation ();
522+
log_diagnostics_result
523+
~tag:("top type constant in join for " ^ faddr)
524+
__FILE__ __LINE__
525+
[iaddr ^ " -- " ^ (register_to_string reg) ^ ": "
526+
^ (p2s (pretty_print_list
527+
(List.map bcd#get_typ result#toList)
528+
(fun ty -> STR (btype_to_string ty))
529+
"[" "; " "]"))];
530+
None
531+
end
532+
508533
end
509534

510535
method resolve_stack_lhs_type

0 commit comments

Comments
 (0)