Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pub
frama-c
Commits
db688bdb
Commit
db688bdb
authored
Dec 17, 2019
by
Patrick Baudin
Browse files
[bit_test] checks for a boolean type
parent
e743d223
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/wp/Cint.ml
View file @
db688bdb
...
@@ -110,7 +110,8 @@ let () = let open LogicBuiltins in add_builtin "\\bit_test" [Z;Z] f_bit_positive
...
@@ -110,7 +110,8 @@ let () = let open LogicBuiltins in add_builtin "\\bit_test" [Z;Z] f_bit_positive
let
f_bits
=
[
f_bit_stdlib
;
f_bit_positive
;
f_bit_export
]
let
f_bits
=
[
f_bit_stdlib
;
f_bit_positive
;
f_bit_export
]
let
bit_test
e
k
=
let
bit_test
e
k
=
F
.
e_fun
(
if
k
<=
0
then
f_bit_positive
else
f_bit_stdlib
)
[
e
;
e_int
k
]
let
r
=
F
.
e_fun
(
if
k
<=
0
then
f_bit_positive
else
f_bit_stdlib
)
[
e
;
e_int
k
]
in
assert
(
is_prop
r
)
;
r
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* --- Matching utilities for simplifications --- *)
(* --- Matching utilities for simplifications --- *)
...
@@ -483,7 +484,7 @@ let smp2 f zf = (* f(c1,c2) ~> zf(c1,c2), f(c1,c2,...) ~> f(zf(c1,c2),...) *)
...
@@ -483,7 +484,7 @@ let smp2 f zf = (* f(c1,c2) ~> zf(c1,c2), f(c1,c2,...) ~> f(zf(c1,c2),...) *)
end
end
|
_
->
raise
Not_found
|
_
->
raise
Not_found
let
bitk_positive
k
e
=
F
.
e_fun
f_bit_positive
[
e
;
k
]
let
bitk_positive
k
e
=
let
r
=
F
.
e_fun
f_bit_positive
[
e
;
k
]
in
assert
(
is_prop
r
)
;
r
let
smp_mk_bit_stdlib
=
function
let
smp_mk_bit_stdlib
=
function
|
[
a
;
k
]
when
is_positive_or_null
k
->
|
[
a
;
k
]
when
is_positive_or_null
k
->
(* No need to expand the logic definition of the ACSL stdlib symbol when
(* No need to expand the logic definition of the ACSL stdlib symbol when
...
@@ -767,12 +768,13 @@ let smp_leq_with_lsr a0 b0 =
...
@@ -767,12 +768,13 @@ let smp_leq_with_lsr a0 b0 =
smp_cmp_with_lsr
e_leq
a0
b0
smp_cmp_with_lsr
e_leq
a0
b0
(* Rewritting at export *)
(* Rewritting at export *)
let
bitk_export
k
e
=
let
r
=
F
.
e_fun
f_bit_export
[
e
;
k
]
in
assert
(
is_prop
r
)
;
r
let
export_eq_with_land
a
b
=
let
export_eq_with_land
a
b
=
let
es
=
match_fun
f_land
a
in
let
es
=
match_fun
f_land
a
in
if
b
==
e_zero
then
if
b
==
e_zero
then
let
k
,_,
es
=
match_binop_one_extraction
f_lsl
es
in
let
k
,_,
es
=
match_binop_one_extraction
f_lsl
es
in
(* e1 & ... & en & (1 << k) = 0 <==> !bit_test(e1 & ... & en, k) *)
(* e1 & ... & en & (1 << k) = 0 <==> !bit_test(e1 & ... & en, k) *)
e_not
(
e_fun
f_
bit_export
[
e_fun
f_land
es
;
k
]
)
e_not
(
bit
k
_export
k
(
e_fun
f_land
es
)
)
else
raise
Not_found
else
raise
Not_found
(* ACSL Semantics *)
(* ACSL Semantics *)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment