Skip to content

Commit 932ac3b

Browse files
committed
Allow non-void types for RichVarinfo
1 parent a10c973 commit 932ac3b

5 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/analyses/basePriv.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ struct
951951
(* sync: M -> (2^M -> (G -> D)) *)
952952
include AbstractLockCenteredBase (ThreadMap) (LockCenteredBase.CPA)
953953

954-
let global_init_thread = RichVarinfo.single ~name:"global_init"
954+
let global_init_thread = RichVarinfo.single ~name:"global_init" ~typ:GoblintCil.voidType
955955
let current_thread (ask: Q.ask): Thread.t =
956956
if !AnalysisState.global_initialization then
957957
ThreadIdDomain.Thread.threadinit (global_init_thread ()) ~multiple:false

src/analyses/wrapperFunctionAnalysis.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ module MallocWrapper : MCPSpec = struct
144144
Format.dprintf "@tid:%s" (ThreadLifted.show t)
145145
in
146146
Format.asprintf "(alloc@sid:%s%t%t)" (Node.show_id node) tid uniq_count
147+
148+
let typ _ = GoblintCil.voidType
147149
end
148150

149151
module NodeVarinfoMap = RichVarinfo.BiVarinfoMap.Make(ThreadNode)

src/common/util/richVarinfo.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
open GoblintCil
22

3-
let create_var name = Cilfacade.create_var @@ makeGlobalVar name voidType
3+
let create_var name typ = Cilfacade.create_var @@ makeGlobalVar name typ
44

5-
let single ~name =
6-
let vi = lazy (create_var name) in
5+
let single ~name ~typ =
6+
let vi = lazy (create_var name typ) in
77
fun () ->
88
Lazy.force vi
99

@@ -21,6 +21,7 @@ module type G =
2121
sig
2222
include Hashtbl.HashedType
2323
val name_varinfo: t -> string
24+
val typ: t -> typ
2425
end
2526

2627
module type H =
@@ -47,7 +48,7 @@ struct
4748
try
4849
XH.find !xh x
4950
with Not_found ->
50-
let vi = create_var (X.name_varinfo x) in
51+
let vi = create_var (X.name_varinfo x) (X.typ x) in
5152
store_f x vi;
5253
vi
5354

src/common/util/richVarinfo.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
open GoblintCil
44

5-
val single: name:string -> (unit -> varinfo)
5+
val single: name:string -> typ:typ -> (unit -> varinfo)
66

77
module type VarinfoMap =
88
sig
@@ -18,6 +18,7 @@ module type G =
1818
sig
1919
include Hashtbl.HashedType
2020
val name_varinfo: t -> string
21+
val typ: t -> typ
2122
end
2223

2324
module type H =

src/witness/witnessGhost.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ struct
1111
| Locked l -> LockDomain.Addr.show l ^ "_locked" (* TODO: valid C name *)
1212
| Multithreaded -> "multithreaded"
1313

14-
(* TODO: define correct types *)
15-
16-
let type_ = function
14+
let typ = function
1715
| Locked _ -> GoblintCil.intType
1816
| Multithreaded -> GoblintCil.intType
1917

@@ -30,7 +28,7 @@ include Map
3028

3129
let variable_entry ~task x =
3230
let variable = name_varinfo x in
33-
let type_ = String.trim (CilType.Typ.show (type_ x)) in (* CIL printer puts space at the end of some types *)
31+
let type_ = String.trim (CilType.Typ.show (typ x)) in (* CIL printer puts space at the end of some types *)
3432
let initial = CilType.Exp.show (initial x) in
3533
YamlWitness.Entry.ghost_variable ~task ~variable ~type_ ~initial
3634

0 commit comments

Comments
 (0)