Skip to content
Snippets Groups Projects
Commit 64c366a8 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[kernel] make is_bool part of the API

parent 85d411ec
No related branches found
No related tags found
No related merge requests found
......@@ -4500,12 +4500,13 @@ let isCharConstPtrType t =
( is_unrollable_ltdef tdef && isLogicBooleanType (unroll_ltdef t))
| Lreal | Lvar _ | Larrow _ -> false
let isBoolType typ = match unrollType typ with
| TInt (IBool, _) -> true
| _ -> false
let rec isLogicPureBooleanType t =
match t with
| Ctype t ->
(match unrollType t with
| TInt(IBool,_) -> true
| _ -> false)
| Ctype t -> isBoolType t
| Ltype ({lt_name = name} as def,_) ->
name = Utf8_logic.boolean ||
(is_unrollable_ltdef def && isLogicPureBooleanType (unroll_ltdef t))
......
......@@ -537,6 +537,16 @@ val isCharArrayType: typ -> bool
(** True if the argument is an integral type (i.e. integer or enum) *)
val isIntegralType: typ -> bool
(** True if the argument is [_Bool]
@since Frama-C+dev
*)
val isBoolType: typ -> bool
(** True if the argument is [_Bool] or [boolean].
@since Frama-C+dev
*)
val isLogicPureBooleanType: logic_type -> bool
(** True if the argument is an integral or pointer type. *)
val isIntegralOrPointerType: typ -> bool
......
......@@ -613,10 +613,6 @@ let cast_to_bool r =
{ eover; eunder = under_from_over eover;
ldeps = r.ldeps; etype = TInt (IBool, []) }
let is_bool typ = match Cil.unrollType typ with
| TInt (IBool, _) -> true
| _ -> false
(* -------------------------------------------------------------------------- *)
(* --- Inlining of defined logic functions and predicates --- *)
(* -------------------------------------------------------------------------- *)
......@@ -851,7 +847,7 @@ let rec eval_term ~alarm_mode env t =
(* See if the cast does something. If not, we can keep eunder as is.*)
if is_noop_cast ~src_typ:t.term_type ~dst_typ:typ
then { r with etype = typ }
else if is_bool typ
else if Cil.isBoolType typ
then cast_to_bool r
else
let eover = cast ~src_typ:r.etype ~dst_typ:typ r.eover in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment