Skip to content

Commit 27cbb66

Browse files
committed
CHB:TYPE: add typeconstant voidptr
1 parent 3c85ef2 commit 27cbb66

File tree

7 files changed

+24
-4
lines changed

7 files changed

+24
-4
lines changed

CodeHawk/CHB/bchlib/bCHFloc.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ object (self)
12581258
self#f#env#mk_offset_memory_variable memref memoff)
12591259
memref_r memoff_r
12601260

1261-
method private get_variable_type (v: variable_t): btype_t traceresult =
1261+
method get_variable_type (v: variable_t): btype_t traceresult =
12621262
let is_zero (x: xpr_t) =
12631263
match x with
12641264
| XConst (IntConst n) -> n#equal numerical_zero

CodeHawk/CHB/bchlib/bCHLibTypes.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,6 +3181,7 @@ type type_constant_t =
31813181
| TyTInt of signedness_t * int
31823182
| TyTStruct of int * string (** bckey, bcname *)
31833183
| TyTFloat of fkind_t
3184+
| TyVoidPtr (** only to be used in the context of a void pointer *)
31843185
| TyTUnknown (** top in type lattice *)
31853186
| TyBottom (** bottom in type lattice *)
31863187

@@ -6020,6 +6021,8 @@ class type floc_int =
60206021
-> xpr_t (** address value *)
60216022
-> variable_t traceresult
60226023

6024+
method get_variable_type: variable_t -> btype_t traceresult
6025+
60236026
method get_xpr_type: xpr_t -> btype_t traceresult
60246027

60256028
(** {2 Predicates on variables}*)

CodeHawk/CHB/bchlib/bCHSumTypeSerializer.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,13 @@ object
559559
| TyTInt _ -> "ti"
560560
| TyTStruct _ -> "ts"
561561
| TyTFloat _ -> "tf"
562+
| TyVoidPtr -> "vp"
562563
| TyTUnknown -> "u"
563564
| TyBottom -> "b"
564565

565566
method !tags = [
566-
"a"; "ac"; "acl"; "ap"; "asl"; "ax"; "b"; "i"; "s"; "ti"; "tf"; "ts"; "u"; "z"]
567+
"a"; "ac"; "acl"; "ap"; "asl"; "ax"; "b"; "i";
568+
"s"; "ti"; "tf"; "ts"; "u"; "vp"; "z"]
567569

568570
end
569571

CodeHawk/CHB/bchlib/bCHSystemSettings.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ let _ =
116116
("LDR-stack-addr", "enable");
117117
("LDR-struct-field", "enable");
118118
("LDRH-memop-tc", "enable");
119-
("POP-sig-rv", "enable")
119+
("POP-sig-rv", "enable");
120+
("STR-memop-tc", "enable")
120121
]
121122

122123

CodeHawk/CHB/bchlib/bCHTypeConstraintDictionary.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
------------------------------------------------------------------------------
55
The MIT License (MIT)
66
7-
Copyright (c) 2024 Aarno Labs LLC
7+
Copyright (c) 2024-2025 Aarno Labs LLC
88
99
Permission is hereby granted, free of charge, to any person obtaining a copy
1010
of this software and associated documentation files (the "Software"), to deal
@@ -171,6 +171,7 @@ object (self)
171171
| TyTInt (sg, si) -> (tags @ [signedness_mfts#ts sg], [si])
172172
| TyTStruct (key, name) -> (tags @ [name], [key])
173173
| TyTFloat k -> (tags @ [fkind_mfts#ts k], [])
174+
| TyVoidPtr -> (tags, [])
174175
| TyBottom -> (tags, [])
175176
| TyTUnknown -> (tags, []) in
176177
type_constant_table#add key
@@ -192,6 +193,7 @@ object (self)
192193
| "ti" -> TyTInt (signedness_mfts#fs (t 1), a 0)
193194
| "tf" -> TyTFloat (fkind_mfts#fs (t 1))
194195
| "ts" -> TyTStruct (a 0, t 1)
196+
| "vp" -> TyVoidPtr
195197
| "b" -> TyBottom
196198
| "u" -> TyTUnknown
197199
| s -> raise_tag_error name s type_constant_mcts#tags

CodeHawk/CHB/bchlib/bCHTypeConstraintStore.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,10 @@ object (self)
543543
match result#toList with
544544
| [ixty1; ixty2] ->
545545
(match (bcd#get_typ ixty1), (bcd#get_typ ixty2) with
546+
| TPtr (TVoid _, _), TPtr _ ->
547+
Some (bcd#get_typ ixty2)
548+
| TPtr _, TPtr (TVoid _, _) ->
549+
Some (bcd#get_typ ixty1)
546550
| TPtr (tty1, _), TPtr (tty2, _)
547551
when is_struct_type tty1 && is_scalar tty2 ->
548552
Some (bcd#get_typ ixty1)

CodeHawk/CHB/bchlib/bCHTypeConstraintUtil.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ let type_constant_to_string (c: type_constant_t) =
140140
^ "(" ^ (string_of_int si) ^ ")"
141141
| TyTStruct (_, name) -> "t_struct_" ^ name
142142
| TyTFloat k -> float_type_to_string k
143+
| TyVoidPtr -> "t_voidptr"
143144
| TyTUnknown -> "t_top"
144145
| TyBottom -> "t_bottom"
145146

@@ -442,6 +443,8 @@ let rec mk_btype_constraint (tv: type_variable_t) (ty: btype_t)
442443
| TComp (key, _) ->
443444
let cinfo = bcfiles#get_compinfo key in
444445
Some (TyGround (TyVariable tv, TyConstant (TyTStruct (key, cinfo.bcname))))
446+
| TPtr (TVoid _, _) ->
447+
Some (TyGround (TyVariable tv, TyConstant TyVoidPtr))
445448
| TPtr (pty, _) ->
446449
let ptv = add_deref_capability tv in
447450
mk_btype_constraint ptv pty
@@ -461,6 +464,10 @@ let rec mk_btype_constraint (tv: type_variable_t) (ty: btype_t)
461464
"Unable to create array access capability (no size): %s [%s:%d]"
462465
(String.concat "; " e)
463466
__FILE__ __LINE__;
467+
log_diagnostics_result
468+
__FILE__ __LINE__
469+
["Unable to create array access capability (no size): "
470+
^ (String.concat "; " e)];
464471
None
465472
end)
466473
| rty ->
@@ -514,6 +521,7 @@ let type_constant_to_btype (tc: type_constant_t) =
514521
TInt (ikind, [])
515522
| TyTStruct (key, _) -> get_compinfo_struct_type (bcfiles#get_compinfo key)
516523
| TyTFloat fkind -> TFloat (fkind, FScalar, [])
524+
| TyVoidPtr -> t_voidptr
517525
| TyBottom -> t_unknown
518526
| TyTUnknown -> t_unknown
519527

0 commit comments

Comments
 (0)