Skip to content

Commit 0c2061f

Browse files
committed
CHB: handle base-ptr array offset
1 parent b255965 commit 0c2061f

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

CodeHawk/CHB/bchlib/bCHFloc.ml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,10 @@ object (self)
12591259
memref_r memoff_r
12601260

12611261
method private get_variable_type (v: variable_t): btype_t traceresult =
1262+
let is_zero (x: xpr_t) =
1263+
match x with
1264+
| XConst (IntConst n) -> n#equal numerical_zero
1265+
| _ -> false in
12621266
if self#f#env#is_initial_register_value v then
12631267
let reg_r = self#f#env#get_initial_register_value_register v in
12641268
TR.tbind
@@ -1348,6 +1352,43 @@ object (self)
13481352
let cinfo = get_compinfo_by_key ckey in
13491353
let finfo = get_compinfo_field cinfo fname in
13501354
Ok finfo.bftype
1355+
| IndexOffset (v, i, memsuboff) ->
1356+
Error [__FILE__ ^ ":" ^ (string_of_int __LINE__) ^ ": "
1357+
^ "index offset: "
1358+
^ (memory_offset_to_string memoff)
1359+
^ " with "
1360+
^ (p2s v#toPretty)
1361+
^ ", index: "
1362+
^ (string_of_int i)
1363+
^ "; and "
1364+
^ (memory_offset_to_string memsuboff)]
1365+
| ArrayIndexOffset (x, memsuboff) ->
1366+
Error [__FILE__ ^ ":" ^ (string_of_int __LINE__) ^ ": "
1367+
^ "array index offset: "
1368+
^ (memory_offset_to_string memoff)
1369+
^ " with "
1370+
^ (x2s x)
1371+
^ "; and "
1372+
^ (memory_offset_to_string memsuboff)]
1373+
| BasePtrArrayIndexOffset (x, _) when is_zero x ->
1374+
(match basevartype with
1375+
| TPtr (t, _) -> Ok t
1376+
| _ ->
1377+
Error [__FILE__ ^ ":" ^ (string_of_int __LINE__) ^ ": "
1378+
^ "array index offset: "
1379+
^ (memory_offset_to_string memoff)
1380+
^ " with basevar type: "
1381+
^ (btype_to_string basevartype)
1382+
^ " not yet handled"])
1383+
| BasePtrArrayIndexOffset (x, memsuboff) ->
1384+
Error [__FILE__ ^ ":" ^ (string_of_int __LINE__) ^ ": "
1385+
^ "base-ptr array index offset: "
1386+
^ (memory_offset_to_string memoff)
1387+
^ " with "
1388+
^ (x2s x)
1389+
^ "; and "
1390+
^ (memory_offset_to_string memsuboff)]
1391+
13511392
| _ ->
13521393
Error [__FILE__ ^ ":" ^ (string_of_int __LINE__) ^ ": "
13531394
^ "memoff: " ^ (memory_offset_to_string memoff)

CodeHawk/CHB/bchlib/bCHVersion.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ end
9595

9696

9797
let version = new version_info_t
98-
~version:"0.6.0_20250714"
99-
~date:"2025-07-14"
98+
~version:"0.6.0_20250716"
99+
~date:"2025-07-16"
100100
~licensee: None
101101
~maxfilesize: None
102102
()

0 commit comments

Comments
 (0)