Skip to content

Commit 3da69f5

Browse files
committed
Remove excessive cast for integer constants
1 parent 4c8ba0a commit 3da69f5

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/analyses/base.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,7 @@ struct
803803
(* Integer literals *)
804804
(* seems like constFold already converts CChr to CInt *)
805805
| Const (CChr x) -> eval_rv ~man st (Const (charConstToInt x)) (* char becomes int, see Cil doc/ISO C 6.4.4.4.10 *)
806-
| Const (CInt (num,ikind,str)) ->
807-
GobOption.iter (fun x -> if M.tracing then M.tracel "casto" "CInt (%s, %a, %s)" (Z.to_string num) d_ikind ikind x) str;
808-
Int (ID.cast_to ikind (IntDomain.of_const (num,ikind,str)))
806+
| Const (CInt (num,ikind,str)) -> Int (IntDomain.of_const (num,ikind,str)) (* no cast to ikind needed: CIL ensures that the literal fits ikind, either by silently truncating it (!) or having an explicit CastE around this *)
809807
| Const (CReal (_,fkind, Some str)) when not (Cilfacade.isComplexFKind fkind) -> Float (FD.of_string fkind str) (* prefer parsing from string due to higher precision *)
810808
| Const (CReal (num, fkind, None)) when not (Cilfacade.isComplexFKind fkind) && num = 0.0 -> Float (FD.of_const fkind num) (* constant 0 is ok, CIL creates these for zero-initializers; it is safe across float types *)
811809
| Const (CReal (_, fkind, None)) when not (Cilfacade.isComplexFKind fkind) -> assert false (* Cil does not create other CReal without string representation *)

0 commit comments

Comments
 (0)