Skip to content

Commit 9ced42c

Browse files
committed
Fix compilation issues after merge
1 parent 99b76d3 commit 9ced42c

File tree

9 files changed

+53
-48
lines changed

9 files changed

+53
-48
lines changed

infer/src/absint/HilExp.ml

+16-26
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,15 @@ module Access = MemoryAccess
1818
We could make only the types of [AddressOf] and [Dereference] private but that proved too
1919
cumbersome... *)
2020
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 =
2422
| AccessExpression of access_expression
2523
| UnaryOperator of Unop.t * t * Typ.t option
2624
| BinaryOperator of Binop.t * t * t
2725
| Exception of t
2826
| Closure of Procname.t * (AccessPath.base * t) list
2927
| Constant of Const.t
3028
| Cast of Typ.t * t
31-
| Sizeof of sizeof_data
32-
(* | Sizeof of Typ.t * t option *)
29+
| Sizeof of Typ.t * t option
3330

3431
and access_expression = private
3532
| Base of AccessPath.base
@@ -56,18 +53,15 @@ module T : sig
5653
remove_deref_after_base:bool -> AccessPath.base -> access_expression -> access_expression
5754
end
5855
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 =
6257
| AccessExpression of access_expression
6358
| UnaryOperator of Unop.t * t * Typ.t option
6459
| BinaryOperator of Binop.t * t * t
6560
| Exception of t
6661
| Closure of Procname.t * (AccessPath.base * t) list
6762
| Constant of Const.t
6863
| Cast of Typ.t * t
69-
| Sizeof of sizeof_data
70-
(* | Sizeof of Typ.t * t option *)
64+
| Sizeof of Typ.t * t option
7165

7266
and access_expression =
7367
| Base of AccessPath.base
@@ -170,25 +164,23 @@ and pp fmt = function
170164
Const.pp Pp.text fmt c
171165
| Cast (typ, e) ->
172166
F.fprintf fmt "(%a) %a" (Typ.pp_full Pp.text) typ pp e
173-
| Sizeof {typ; dynamic_length} ->
167+
| Sizeof (typ, length) ->
174168
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
176170

177171

178172
let get_access_exprs exp0 =
179173
let rec get_access_exprs_ exp acc =
180174
match exp with
181175
| AccessExpression ae ->
182176
ae :: acc
183-
| Cast (_, e) | UnaryOperator (_, e, _) | Exception e ->
177+
| Cast (_, e) | UnaryOperator (_, e, _) | Exception e | Sizeof (_, Some e) ->
184178
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)
187179
| BinaryOperator (_, e1, e2) ->
188180
get_access_exprs_ e1 acc |> get_access_exprs_ e2
189181
| Closure (_, captured) ->
190182
List.fold captured ~f:(fun acc (_, e) -> get_access_exprs_ e acc) ~init:acc
191-
| Constant _ ->
183+
| Constant _ | Sizeof _ ->
192184
acc
193185
in
194186
get_access_exprs_ exp0 []
@@ -239,6 +231,10 @@ module AccessExpression = struct
239231
get_base ae
240232

241233

234+
let dereference_2 access = dereference access
235+
236+
let is_base = function Base _ -> true | _ -> false
237+
242238
let lookup_field_type_annot tenv base_typ field_name =
243239
let lookup = Tenv.lookup tenv in
244240
Struct.get_field_type_and_annotation ~lookup field_name base_typ
@@ -303,8 +299,8 @@ module AccessExpression = struct
303299
fold_vars_exp exp ~init ~f )
304300
| Constant _ ->
305301
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
308304

309305

310306
let truncate = function
@@ -520,14 +516,8 @@ and of_sil ~include_array_indexes ~f_resolve_id ~add_deref exp typ =
520516
Constant c
521517
| Cast (cast_typ, e) ->
522518
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)
531521
| Closure closure ->
532522
let environment =
533523
List.map

infer/src/absint/HilExp.mli

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ type t =
1717
| Closure of Procname.t * (AccessPath.base * t) list (** Name of function + environment *)
1818
| Constant of Const.t (** Constants *)
1919
| Cast of Typ.t * t (** Type cast *)
20-
| Sizeof of sizeof_data
21-
(* | Sizeof of Typ.t * t option *)
20+
| Sizeof of Typ.t * t option
2221
(** C-style sizeof(), and also used to treate a type as an expression. Refer to [Exp] module
2322
for canonical documentation *)
2423

@@ -49,6 +48,10 @@ module AccessExpression : sig
4948

5049
val get_base : access_expression -> AccessPath.base
5150

51+
val dereference_2 : access_expression -> access_expression
52+
53+
val is_base : access_expression -> bool
54+
5255
val replace_base :
5356
remove_deref_after_base:bool -> AccessPath.base -> access_expression -> access_expression
5457

infer/src/backend/Payloads.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ module SQLite = struct
192192
; buffer_overrun_checker= lazy (load table ~proc_uid BufferOverrunChecker)
193193
; config_impact_analysis= lazy (load table ~proc_uid ConfigImpactAnalysis)
194194
; cost= lazy (load table ~proc_uid Cost)
195-
; looper= lazy (load table ~rowid Looper)
195+
; looper= lazy (load table ~proc_uid Looper)
196196
; disjunctive_demo= lazy (load table ~proc_uid DisjunctiveDemo)
197197
; lab_resource_leaks= lazy (load table ~proc_uid LabResourceLeaks)
198198
; litho_required_props= lazy (load table ~proc_uid LithoRequiredProps)

infer/src/looper/EdgeExp.ml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ let rec remove_casts_of_consts exp integer_widths =
13231323
then
13241324
match Typ.get_ikind_opt typ with
13251325
| Some ikind ->
1326-
let type_max_value = Z.((Typ.range_of_ikind integer_widths ikind |> snd) + ~$1) in
1326+
let type_max_value = Z.((IntegerWidths.range_of_ikind integer_widths ikind |> snd) + ~$1) in
13271327
let value_after_cast = IntLit.of_big_int Z.(type_max_value - IntLit.to_big_int c) in
13281328
Const (Const.Cint value_after_cast)
13291329
| None ->
@@ -2293,7 +2293,7 @@ and access_exprs_of_exp ~include_array_indexes ~f_resolve_id ~test_resolver ~for
22932293
complex expressions instead of just access expressions
22942294
as it was originally *)
22952295
map_accesses value ~init:None ~f:(fun ae None ->
2296-
let ae = if add_deref then HilExp.AccessExpression.dereference ae else ae in
2296+
let ae = if add_deref then HilExp.AccessExpression.dereference_2 ae else ae in
22972297
(Access (map_formal ae formal_map |> add_accesses), None) )
22982298
|> fst
22992299
in
@@ -2304,7 +2304,7 @@ and access_exprs_of_exp ~include_array_indexes ~f_resolve_id ~test_resolver ~for
23042304
ValuePair.P (process_value lb, process_value ub) :: acc )
23052305
| None, missing_id ->
23062306
let ae = HilExp.AccessExpression.address_of_base (base_of_id id typ) in
2307-
let ae = if add_deref then HilExp.AccessExpression.dereference ae else ae in
2307+
let ae = if add_deref then HilExp.AccessExpression.dereference_2 ae else ae in
23082308
ValuePair.V (Access (map_formal ae formal_map |> add_accesses)) :: acc
23092309
(* match f_resolve_id (Var.of_id id) with
23102310
| Some access_expr ->
@@ -2344,12 +2344,12 @@ and access_exprs_of_exp ~include_array_indexes ~f_resolve_id ~test_resolver ~for
23442344
| None, missing_id ->
23452345
let access_expr = of_pvar pvar typ in
23462346
let access_expr =
2347-
if add_deref then HilExp.AccessExpression.dereference access_expr else access_expr
2347+
if add_deref then HilExp.AccessExpression.dereference_2 access_expr else access_expr
23482348
in
23492349
ValuePair.V (Access (map_formal access_expr formal_map |> add_accesses)) :: acc )
23502350
| Lvar pvar ->
23512351
let ae = of_pvar pvar typ in
2352-
let ae = if add_deref then HilExp.AccessExpression.dereference ae else ae in
2352+
let ae = if add_deref then HilExp.AccessExpression.dereference_2 ae else ae in
23532353
ValuePair.V (Access (map_formal ae formal_map |> add_accesses)) :: acc
23542354
| Lfield (root_exp, fld, root_exp_typ) ->
23552355
let add_field_access_expr access_expr =
@@ -2457,7 +2457,7 @@ and of_sil_exp ~include_array_indexes ~f_resolve_id ~test_resolver ~formal_map ~
24572457
| Some value_pair, _ -> (
24582458
let process_value value =
24592459
map_accesses value ~init:None ~f:(fun ae None ->
2460-
let ae = if add_deref then HilExp.AccessExpression.dereference ae else ae in
2460+
let ae = if add_deref then HilExp.AccessExpression.dereference_2 ae else ae in
24612461
let mapped_ae = map_formal ae formal_map in
24622462
(Access mapped_ae, None) )
24632463
|> fst
@@ -2470,7 +2470,7 @@ and of_sil_exp ~include_array_indexes ~f_resolve_id ~test_resolver ~formal_map ~
24702470
| None, missing ->
24712471
let access_expr = HilExp.AccessExpression.of_id id typ in
24722472
let access_expr =
2473-
if add_deref then HilExp.AccessExpression.dereference access_expr else access_expr
2473+
if add_deref then HilExp.AccessExpression.dereference_2 access_expr else access_expr
24742474
in
24752475
ValuePair.V (Access access_expr)
24762476
(* let ae = match f_resolve_id (Var.of_id id) with

infer/src/looper/EdgeExp.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ val separate : T.t -> T.t * (Binop.t * IntLit.t) option
153153

154154
val simplify : T.t -> T.t
155155

156-
val remove_casts_of_consts : T.t -> Typ.IntegerWidths.t -> T.t
156+
val remove_casts_of_consts : T.t -> IntegerWidths.t -> T.t
157157

158158
val evaluate_const_exp : T.t -> IntLit.t option
159159

infer/src/looper/GraphConstructor.ml

+17-7
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ let exec_instr :
382382
(fun ptr_arg (lb, ub) acc ->
383383
debug_log "Side-effect: %a ---> [%a, %a]@," EdgeExp.pp ptr_arg EdgeExp.pp lb
384384
EdgeExp.pp ub ;
385-
let arg_access = HilExp.AccessExpression.dereference (extract_access ptr_arg) in
385+
let arg_access = HilExp.AccessExpression.dereference_2 (extract_access ptr_arg) in
386386
let output_bound = EdgeExp.ValuePair.P (lb, ub) in
387387
LTS.EdgeData.add_assignment acc arg_access output_bound )
388388
call_model.side_effects graph_data.edge_data
@@ -401,7 +401,7 @@ let exec_instr :
401401
let locals =
402402
AccessExpressionSet.fold
403403
(fun access locals_acc ->
404-
let access = HilExp.AccessExpression.dereference access in
404+
let access = HilExp.AccessExpression.dereference_2 access in
405405
debug_log "Checking if local: %a@," HilExp.AccessExpression.pp access ;
406406
let access_base = HilExp.AccessExpression.get_base access in
407407
let is_formal = AccessPath.BaseSet.mem access_base proc_data.formals in
@@ -839,7 +839,7 @@ let exec_instr :
839839
(graph_data, proc_data) )
840840
| Metadata metadata -> (
841841
match metadata with
842-
| VariableLifetimeBegins (pvar, typ, loc) ->
842+
| VariableLifetimeBegins {pvar; typ; loc} ->
843843
debug_log "@[<v4>[VariableLifetimeBegins] %a@,Variable: %a@," Location.pp loc Pvar.pp_value
844844
pvar ;
845845
let pvar_base_access = HilExp.AccessExpression.base (AccessPath.base_of_pvar pvar typ) in
@@ -1055,16 +1055,26 @@ let process_split_node node successors predecessors (graph_data, proc_data) =
10551055
(* Check if it is a loop head and add the join node into scope stack *)
10561056
let prev_node = List.hd_exn predecessors in
10571057
let prev_is_loop_head = Procdesc.is_loop_head graph_data.proc_desc prev_node in
1058-
let node_map =
1059-
if prev_is_loop_head then Procdesc.NodeMap.add prev_node prune_node graph_data.node_map
1060-
else Procdesc.NodeMap.add node prune_node graph_data.node_map
1058+
let current_is_loop_head = Procdesc.is_loop_head graph_data.proc_desc node in
1059+
let node_map, loop_heads =
1060+
if prev_is_loop_head then (
1061+
let node_map = Procdesc.NodeMap.add prev_node prune_node graph_data.node_map in
1062+
node_map, graph_data.loop_heads
1063+
) else if current_is_loop_head then (
1064+
let loop_heads = prune_node :: graph_data.loop_heads in
1065+
Procdesc.NodeMap.add node prune_node graph_data.node_map, loop_heads
1066+
) else (
1067+
Procdesc.NodeMap.add node prune_node graph_data.node_map,
1068+
graph_data.loop_heads
1069+
)
10611070
in
10621071
let graph_data =
10631072
{ graph_data with
10641073
last_split_info= Some (prune_node, current_if_kind)
10651074
; last_node= prune_node
10661075
; edge_data= LTS.EdgeData.default
1067-
; node_map }
1076+
; node_map
1077+
; loop_heads }
10681078
in
10691079
let proc_data =
10701080
{ proc_data with

infer/src/looper/LooperCostModels.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module LooperModelEnv = struct
2424
; node_hash: int
2525
; location: Location.t
2626
; tenv: Tenv.t
27-
; integer_type_widths: Typ.IntegerWidths.t
27+
; integer_type_widths: IntegerWidths.t
2828
; get_summary: Procname.t -> LooperSummary.t option }
2929

3030
let mk_model_env pname ~node_hash location tenv integer_type_widths get_summary =
@@ -180,7 +180,7 @@ let get_strtoul_model ~of_function arg_pairs widths =
180180
in
181181
(complexity, cache)
182182
in
183-
let ret_lb, ret_ub = Typ.range_of_ikind widths Typ.IULong in
183+
let ret_lb, ret_ub = IntegerWidths.range_of_ikind widths Typ.IULong in
184184
let output_bound =
185185
( EdgeExp.T.Const (Const.Cint (IntLit.of_big_int ret_lb))
186186
, EdgeExp.T.Const (Const.Cint (IntLit.of_big_int ret_ub)) )

opam/infer.opam

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ depends: [
5151
"yojson" {>="1.7.0"}
5252
"zarith" {>="1.12"}
5353
"why3"
54+
"ocaml-lsp-server"
5455
]
5556
build: [
5657
["./autogen.sh"]

opam/infer.opam.locked

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ depends: [
4343
"cppo" {= "1.6.9"}
4444
"csexp" {= "1.5.1"}
4545
"ctypes" {= "0.20.1"}
46-
"dune" {= "3.7.1"}
46+
"dune" {= "3.7.0"}
4747
"dune-configurator" {= "3.7.0"}
4848
"easy-format" {= "1.3.4"}
4949
"expect_test_helpers_core" {= "v0.15.0"}
@@ -158,6 +158,7 @@ depends: [
158158
"zarith" {= "1.12"}
159159
"why3" {= "1.6.0"}
160160
"zed" {= "3.2.1"}
161+
"ocaml-lsp-server" {= "1.17.0"}
161162
]
162163
build: [
163164
["./autogen.sh"]
@@ -170,4 +171,4 @@ depexts: [
170171
["default-jdk"] {"ubuntu"}
171172
["default-jdk"] {"debian"}
172173
]
173-
dev-repo: "git://github.com/facebook/infer.git"
174+
dev-repo: "git://github.com/facebook/infer.git"

0 commit comments

Comments
 (0)