Skip to content

Commit 9e94c3a

Browse files
committed
CHB: disable first-field check for structs
1 parent 66f2600 commit 9e94c3a

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

CodeHawk/CHB/bchlib/bCHTypeConstraintStore.ml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ object (self)
524524
| Error _ -> None
525525
| Ok ftype ->
526526
let ixftype = bcd#index_typ ftype in
527-
let ixctype = bcd#index_typ tstructarray in
527+
let ixctype = bcd#index_typ ty in
528528
let _ =
529529
chlog#add
530530
"first field struct check"
@@ -539,10 +539,39 @@ object (self)
539539
STR cinfo.bcname;
540540
STR ": first field type: ";
541541
STR (btype_to_string ftype)]) in
542+
(* TBD: restore this check in a better way
542543
if s#fold (fun acc i -> acc && (i = ixftype || i = ixctype)) true then
543544
Some tstructarray
544545
else
545-
None)
546+
None)*)
547+
Some tstructarray)
548+
| Some (TComp _ as ty) ->
549+
let cinfo = get_struct_type_compinfo ty in
550+
let finfo0 = List.hd cinfo.bcfields in
551+
let ftype = resolve_type finfo0.bftype in
552+
(match ftype with
553+
| Error _ -> None
554+
| Ok ftype ->
555+
let ixftype = bcd#index_typ ftype in
556+
let ixctype = bcd#index_typ ty in
557+
let _ =
558+
chlog#add
559+
"first field struct check (TComp case)"
560+
(LBLOCK [
561+
INT offset;
562+
STR ": ";
563+
pretty_print_list
564+
s#toList
565+
(fun i -> STR (btype_to_string (bcd#get_typ i)))
566+
"{" "; " "}";
567+
STR ": compinfo: ";
568+
STR cinfo.bcname;
569+
STR ": first field type: ";
570+
STR (btype_to_string ftype)]) in
571+
if s#fold (fun acc i -> acc & (i = ixftype || i = ixctype)) true then
572+
Some ftype
573+
else
574+
None)
546575
| _ -> None in
547576
let result = new IntCollections.set_t in
548577
begin

0 commit comments

Comments
 (0)