@@ -18,18 +18,15 @@ module Access = MemoryAccess
18
18
We could make only the types of [AddressOf] and [Dereference] private but that proved too
19
19
cumbersome... *)
20
20
module T : sig
21
- type sizeof_data = {typ : Typ .t ; nbytes : int option ; dynamic_length : t option ; subtype : Subtype .t }
22
-
23
- and t =
21
+ type t =
24
22
| AccessExpression of access_expression
25
23
| UnaryOperator of Unop .t * t * Typ .t option
26
24
| BinaryOperator of Binop .t * t * t
27
25
| Exception of t
28
26
| Closure of Procname .t * (AccessPath .base * t ) list
29
27
| Constant of Const .t
30
28
| Cast of Typ .t * t
31
- | Sizeof of sizeof_data
32
- (* | Sizeof of Typ.t * t option *)
29
+ | Sizeof of Typ .t * t option
33
30
34
31
and access_expression = private
35
32
| Base of AccessPath. base
@@ -56,18 +53,15 @@ module T : sig
56
53
remove_deref_after_base :bool -> AccessPath .base -> access_expression -> access_expression
57
54
end
58
55
end = struct
59
- type sizeof_data = {typ : Typ .t ; nbytes : int option ; dynamic_length : t option ; subtype : Subtype .t }
60
-
61
- and t =
56
+ type t =
62
57
| AccessExpression of access_expression
63
58
| UnaryOperator of Unop .t * t * Typ .t option
64
59
| BinaryOperator of Binop .t * t * t
65
60
| Exception of t
66
61
| Closure of Procname .t * (AccessPath .base * t ) list
67
62
| Constant of Const .t
68
63
| Cast of Typ .t * t
69
- | Sizeof of sizeof_data
70
- (* | Sizeof of Typ.t * t option *)
64
+ | Sizeof of Typ .t * t option
71
65
72
66
and access_expression =
73
67
| Base of AccessPath. base
@@ -170,25 +164,23 @@ and pp fmt = function
170
164
Const. pp Pp. text fmt c
171
165
| Cast (typ , e ) ->
172
166
F. fprintf fmt " (%a) %a" (Typ. pp_full Pp. text) typ pp e
173
- | Sizeof { typ; dynamic_length} ->
167
+ | Sizeof ( typ , length ) ->
174
168
let pp_length fmt = Option. iter ~f: (F. fprintf fmt " [%a]" pp) in
175
- F. fprintf fmt " sizeof(%a%a)" (Typ. pp_full Pp. text) typ pp_length dynamic_length
169
+ F. fprintf fmt " sizeof(%a%a)" (Typ. pp_full Pp. text) typ pp_length length
176
170
177
171
178
172
let get_access_exprs exp0 =
179
173
let rec get_access_exprs_ exp acc =
180
174
match exp with
181
175
| AccessExpression ae ->
182
176
ae :: acc
183
- | Cast (_ , e ) | UnaryOperator (_ , e , _ ) | Exception e ->
177
+ | Cast (_ , e ) | UnaryOperator (_ , e , _ ) | Exception e | Sizeof ( _ , Some e ) ->
184
178
get_access_exprs_ e acc
185
- | Sizeof {dynamic_length} ->
186
- Option. value_map dynamic_length ~default: acc ~f: (fun e -> get_access_exprs_ e acc)
187
179
| BinaryOperator (_ , e1 , e2 ) ->
188
180
get_access_exprs_ e1 acc |> get_access_exprs_ e2
189
181
| Closure (_ , captured ) ->
190
182
List. fold captured ~f: (fun acc (_ , e ) -> get_access_exprs_ e acc) ~init: acc
191
- | Constant _ ->
183
+ | Constant _ | Sizeof _ ->
192
184
acc
193
185
in
194
186
get_access_exprs_ exp0 []
@@ -239,6 +231,10 @@ module AccessExpression = struct
239
231
get_base ae
240
232
241
233
234
+ let dereference_2 access = dereference access
235
+
236
+ let is_base = function Base _ -> true | _ -> false
237
+
242
238
let lookup_field_type_annot tenv base_typ field_name =
243
239
let lookup = Tenv. lookup tenv in
244
240
Struct. get_field_type_and_annotation ~lookup field_name base_typ
@@ -303,8 +299,8 @@ module AccessExpression = struct
303
299
fold_vars_exp exp ~init ~f )
304
300
| Constant _ ->
305
301
init
306
- | Sizeof {dynamic_length} ->
307
- fold_vars_exp_opt dynamic_length ~init ~f
302
+ | Sizeof ( _ , exp_opt ) ->
303
+ fold_vars_exp_opt exp_opt ~init ~f
308
304
309
305
310
306
let truncate = function
@@ -520,14 +516,8 @@ and of_sil ~include_array_indexes ~f_resolve_id ~add_deref exp typ =
520
516
Constant c
521
517
| Cast (cast_typ , e ) ->
522
518
Cast (cast_typ, of_sil_ e typ)
523
- | Sizeof data ->
524
- let hil_data : sizeof_data =
525
- { typ= data.typ
526
- ; nbytes= data.nbytes
527
- ; dynamic_length= Option. map ~f: (fun e -> of_sil_ e typ) data.dynamic_length
528
- ; subtype= data.subtype }
529
- in
530
- Sizeof hil_data
519
+ | Sizeof {typ; dynamic_length} ->
520
+ Sizeof (typ, Option. map ~f: (fun e -> of_sil_ e typ) dynamic_length)
531
521
| Closure closure ->
532
522
let environment =
533
523
List. map
0 commit comments