Skip to content

Commit

Permalink
Use VS domain instead of AD for MustProtectedVars
Browse files Browse the repository at this point in the history
  • Loading branch information
karoliineh committed Sep 18, 2023
1 parent 3879fdc commit 2917999
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
11 changes: 3 additions & 8 deletions src/analyses/commonPriv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,10 @@ struct
ask.f (Q.MustBeProtectedBy {mutex=m; global=x; write=true; protection})

let protected_vars (ask: Q.ask): varinfo list =
let module VS = Set.Make (CilType.Varinfo) in
Q.AD.fold (fun m acc ->
Q.AD.fold (fun l acc ->
match l with
| Q.AD.Addr.Addr (v,_) -> VS.add v acc (* always `NoOffset from mutex analysis *)
| _ -> acc
) (ask.f (Q.MustProtectedVars {mutex = m; write = true})) acc
) (ask.f Q.MustLockset) VS.empty
|> VS.elements
Q.VS.join (ask.f (Q.MustProtectedVars {mutex = m; write = true})) acc
) (ask.f Q.MustLockset) (Q.VS.empty ())
|> Q.VS.elements
end

module MutexGlobals =
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/mutexAnalysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ struct
| Queries.MustProtectedVars {mutex = m; write} ->
let protected = GProtected.get ~write Strong (G.protected (ctx.global (V.protected m))) in
VarSet.fold (fun v acc ->
Queries.AD.join (Queries.AD.of_var v) acc
) protected (Queries.AD.empty ())
Queries.VS.add v acc
) protected (Queries.VS.empty ())
| Queries.IterSysVars (Global g, f) ->
f (Obj.repr (V.protecting g)) (* TODO: something about V.protected? *)
| WarnGlobal g ->
Expand Down
6 changes: 3 additions & 3 deletions src/domains/queries.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ type _ t =
| CreatedThreads: ConcDomain.ThreadSet.t t
| MustJoinedThreads: ConcDomain.MustThreadSet.t t
| ThreadsJoinedCleanly: MustBool.t t
| MustProtectedVars: mustprotectedvars -> AD.t t
| MustProtectedVars: mustprotectedvars -> VS.t t
| Invariant: invariant_context -> Invariant.t t
| InvariantGlobal: Obj.t -> Invariant.t t (** Argument must be of corresponding [Spec.V.t]. *)
| WarnGlobal: Obj.t -> Unit.t t (** Argument must be of corresponding [Spec.V.t]. *)
Expand Down Expand Up @@ -179,7 +179,7 @@ struct
| CreatedThreads -> (module ConcDomain.ThreadSet)
| MustJoinedThreads -> (module ConcDomain.MustThreadSet)
| ThreadsJoinedCleanly -> (module MustBool)
| MustProtectedVars _ -> (module AD)
| MustProtectedVars _ -> (module VS)
| Invariant _ -> (module Invariant)
| InvariantGlobal _ -> (module Invariant)
| WarnGlobal _ -> (module Unit)
Expand Down Expand Up @@ -243,7 +243,7 @@ struct
| CreatedThreads -> ConcDomain.ThreadSet.top ()
| MustJoinedThreads -> ConcDomain.MustThreadSet.top ()
| ThreadsJoinedCleanly -> MustBool.top ()
| MustProtectedVars _ -> AD.top ()
| MustProtectedVars _ -> VS.top ()
| Invariant _ -> Invariant.top ()
| InvariantGlobal _ -> Invariant.top ()
| WarnGlobal _ -> Unit.top ()
Expand Down

0 comments on commit 2917999

Please sign in to comment.