@@ -118,7 +118,11 @@ struct
118118 | AlignOf _
119119 | AlignOfE _
120120 | UnOp _
121- | BinOp _ -> false
121+ | BinOp _
122+ | Question _
123+ | Real _
124+ | Imag _
125+ | AddrOfLabel _ -> false
122126 | Const _ -> true
123127 | AddrOf (Var v2,_)
124128 | StartOf (Var v2,_)
@@ -127,8 +131,6 @@ struct
127131 | StartOf (Mem e,_)
128132 | Lval (Mem e,_)
129133 | CastE (_ ,e ) -> interesting e
130- | Question _ -> failwith " Logical operations should be compiled away by CIL."
131- | _ -> failwith " Unmatched pattern."
132134
133135 (* helper to decide equality *)
134136 let query_exp_equal ask e1 e2 g s =
@@ -157,8 +159,11 @@ struct
157159 | SizeOfE _
158160 | SizeOfStr _
159161 | AlignOf _
160- | AlignOfE _ -> false
161- | UnOp (_ ,e ,_ ) -> type_may_change_t e bt
162+ | AlignOfE _
163+ | AddrOfLabel _ -> false (* TODO: some may contain exps? *)
164+ | UnOp (_,e,_)
165+ | Real e
166+ | Imag e -> type_may_change_t e bt
162167 | BinOp (_ ,e1 ,e2 ,_ ) -> type_may_change_t e1 bt || type_may_change_t e2 bt
163168 | Lval (Var _,o)
164169 | AddrOf (Var _,o)
@@ -167,8 +172,7 @@ struct
167172 | AddrOf (Mem e,o)
168173 | StartOf (Mem e ,o ) -> may_change_t_offset o || type_may_change_t e bt
169174 | CastE (t ,e ) -> type_may_change_t e bt
170- | Question _ -> failwith " Logical operations should be compiled away by CIL."
171- | _ -> failwith " Unmatched pattern."
175+ | Question (b , t , f , _ ) -> type_may_change_t b bt || type_may_change_t t bt || type_may_change_t f bt
172176 in
173177 let bt = unrollTypeDeep (Cilfacade. typeOf b) in
174178 type_may_change_t a bt
@@ -191,8 +195,11 @@ struct
191195 | SizeOfE _
192196 | SizeOfStr _
193197 | AlignOf _
194- | AlignOfE _ -> false
195- | UnOp (_ ,e ,_ ) -> lval_may_change_pt e bl
198+ | AlignOfE _
199+ | AddrOfLabel _ -> false (* TODO: some may contain exps? *)
200+ | UnOp (_,e,_)
201+ | Real e
202+ | Imag e -> lval_may_change_pt e bl
196203 | BinOp (_ ,e1 ,e2 ,_ ) -> lval_may_change_pt e1 bl || lval_may_change_pt e2 bl
197204 | Lval (Var _,o)
198205 | AddrOf (Var _,o)
@@ -201,8 +208,7 @@ struct
201208 | AddrOf (Mem e,o)
202209 | StartOf (Mem e ,o ) -> may_change_pt_offset o || lval_may_change_pt e bl
203210 | CastE (t ,e ) -> lval_may_change_pt e bl
204- | Question _ -> failwith " Logical operations should be compiled away by CIL."
205- | _ -> failwith " Unmatched pattern."
211+ | Question (b , t , f , _ ) -> lval_may_change_pt t bl || lval_may_change_pt t bl || lval_may_change_pt f bl
206212 in
207213 let bls = pt b in
208214 if Queries.LS. is_top bls
@@ -258,8 +264,11 @@ struct
258264 | SizeOfE _
259265 | SizeOfStr _
260266 | AlignOf _
261- | AlignOfE _ -> false
262- | UnOp (_ ,e ,_ ) -> type_may_change_t deref e
267+ | AlignOfE _
268+ | AddrOfLabel _ -> false (* TODO: some may contain exps? *)
269+ | UnOp (_,e,_)
270+ | Real e
271+ | Imag e -> type_may_change_t deref e
263272 | BinOp (_ ,e1 ,e2 ,_ ) -> type_may_change_t deref e1 || type_may_change_t deref e2
264273 | Lval (Var _,o)
265274 | AddrOf (Var _,o)
@@ -268,8 +277,7 @@ struct
268277 | AddrOf (Mem e ,o ) -> (* Messages.warn "Addr" ;*) may_change_t_offset o || type_may_change_t false e
269278 | StartOf (Mem e ,o ) -> (* Messages.warn "Start";*) may_change_t_offset o || type_may_change_t false e
270279 | CastE (t ,e ) -> type_may_change_t deref e
271- | Question _ -> failwith " Logical operations should be compiled away by CIL."
272- | _ -> failwith " Unmatched pattern."
280+ | Question (b , t , f , _ ) -> type_may_change_t deref b || type_may_change_t deref t || type_may_change_t deref f
273281
274282 and lval_may_change_pt a bl : bool =
275283 let rec may_change_pt_offset o =
@@ -324,8 +332,11 @@ struct
324332 | SizeOfE _
325333 | SizeOfStr _
326334 | AlignOf _
327- | AlignOfE _ -> false
328- | UnOp (_ ,e ,_ ) -> lval_may_change_pt e bl
335+ | AlignOfE _
336+ | AddrOfLabel _ -> false (* TODO: some may contain exps? *)
337+ | UnOp (_,e,_)
338+ | Real e
339+ | Imag e -> lval_may_change_pt e bl
329340 | BinOp (_ ,e1 ,e2 ,_ ) -> lval_may_change_pt e1 bl || lval_may_change_pt e2 bl
330341 | Lval (Var _,o)
331342 | AddrOf (Var _,o)
@@ -334,8 +345,7 @@ struct
334345 | AddrOf (Mem e,o)
335346 | StartOf (Mem e ,o ) -> may_change_pt_offset o || lval_may_change_pt e bl
336347 | CastE (t ,e ) -> lval_may_change_pt e bl
337- | Question _ -> failwith " Logical operations should be compiled away by CIL."
338- | _ -> failwith " Unmatched pattern."
348+ | Question (b , t , f , _ ) -> lval_may_change_pt b bl || lval_may_change_pt t bl || lval_may_change_pt f bl
339349 in
340350 let r =
341351 if Queries.LS. is_top bls || Queries.LS. mem (dummyFunDec.svar, `NoOffset ) bls
@@ -373,7 +383,11 @@ struct
373383 | AlignOf _
374384 | AlignOfE _
375385 | UnOp _
376- | BinOp _ -> None
386+ | BinOp _
387+ | Question _
388+ | AddrOfLabel _
389+ | Real _
390+ | Imag _ -> None
377391 | Const _ -> Some false
378392 | Lval (Var v ,_ ) ->
379393 Some (v.vglob || (ask.f (Queries. IsMultiple v)))
@@ -388,8 +402,6 @@ struct
388402 | AddrOf lv -> Some false (* TODO: sound?! *)
389403 | StartOf (Var v ,_ ) -> Some (ask.f (Queries. IsMultiple v)) (* Taking an address of a global is fine*)
390404 | StartOf lv -> Some false (* TODO: sound?! *)
391- | Question _ -> failwith " Logical operations should be compiled away by CIL."
392- | _ -> failwith " Unmatched pattern."
393405
394406 (* Set given lval equal to the result of given expression. On doubt do nothing. *)
395407 let add_eq ask (lv :lval ) (rv :Exp.t ) st =
@@ -551,6 +563,10 @@ struct
551563 | AlignOfE _
552564 | UnOp _
553565 | BinOp _
566+ | Question _
567+ | AddrOfLabel _
568+ | Real _
569+ | Imag _
554570 | AddrOf (Var _,_)
555571 | StartOf (Var _,_)
556572 | Lval (Var _ ,_ ) -> eq_set e s
@@ -562,8 +578,6 @@ struct
562578 Queries.ES. map (fun e -> Lval (mkMem ~addr: e ~off: ofs)) (eq_set_clos e s)
563579 | CastE (t ,e ) ->
564580 Queries.ES. map (fun e -> CastE (t,e)) (eq_set_clos e s)
565- | Question _ -> failwith " Logical operations should be compiled away by CIL."
566- | _ -> failwith " Unmatched pattern."
567581
568582
569583 let query ctx (type a ) (x : a Queries.t ): a Queries.result =
0 commit comments