Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
8a633be2
Commit
8a633be2
authored
4 years ago
by
David Bühler
Browse files
Options
Downloads
Patches
Plain Diff
[Eva] Eval_terms: removes some global open.
parent
e39e22de
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/value/legacy/eval_terms.ml
+24
-24
24 additions, 24 deletions
src/plugins/value/legacy/eval_terms.ml
with
24 additions
and
24 deletions
src/plugins/value/legacy/eval_terms.ml
+
24
−
24
View file @
8a633be2
...
@@ -21,15 +21,12 @@
...
@@ -21,15 +21,12 @@
(**************************************************************************)
(**************************************************************************)
open
Cil_types
open
Cil_types
open
Cil_datatype
open
Locations
open
Locations
open
Abstract_interp
open
Cvalue
open
Cvalue
open
Bit_utils
(* Truth values for a predicate analyzed by the value analysis *)
(* Truth values for a predicate analyzed by the value analysis *)
type
predicate_status
=
Comp
.
result
=
True
|
False
|
Unknown
type
predicate_status
=
Abstract_interp
.
Comp
.
result
=
True
|
False
|
Unknown
let
string_of_predicate_status
=
function
let
string_of_predicate_status
=
function
|
Unknown
->
"unknown"
|
Unknown
->
"unknown"
...
@@ -172,6 +169,7 @@ let contains_invalid_loc access loc =
...
@@ -172,6 +169,7 @@ let contains_invalid_loc access loc =
to force its re-evaluation.
to force its re-evaluation.
*)
*)
module
Logic_label
=
Cil_datatype
.
Logic_label
type
labels_states
=
Cvalue
.
Model
.
t
Logic_label
.
Map
.
t
type
labels_states
=
Cvalue
.
Model
.
t
Logic_label
.
Map
.
t
let
join_label_states
m1
m2
=
let
join_label_states
m1
m2
=
...
@@ -319,9 +317,9 @@ let bind_logic_vars env lvs =
...
@@ -319,9 +317,9 @@ let bind_logic_vars env lvs =
|
Lreal
->
bind_logic_var
top_float
|
Lreal
->
bind_logic_var
top_float
|
Ctype
ctyp
when
Cil
.
isIntegralType
ctyp
->
|
Ctype
ctyp
when
Cil
.
isIntegralType
ctyp
->
let
base
=
Base
.
of_c_logic_var
lv
in
let
base
=
Base
.
of_c_logic_var
lv
in
let
size
=
Int
.
of_int
(
Cil
.
bitsSizeOf
ctyp
)
in
let
size
=
Int
eger
.
of_int
(
Cil
.
bitsSizeOf
ctyp
)
in
let
v
=
Cvalue
.
V_Or_Uninitialized
.
initialized
V
.
top_int
in
let
v
=
Cvalue
.
V_Or_Uninitialized
.
initialized
V
.
top_int
in
let
state
=
Model
.
add_base_value
base
~
size
v
~
size_v
:
Int
.
one
state
in
let
state
=
Model
.
add_base_value
base
~
size
v
~
size_v
:
Int
eger
.
one
state
in
state
,
logic_vars
state
,
logic_vars
|
_
->
unsupported_lvar
lv
|
_
->
unsupported_lvar
lv
in
in
...
@@ -581,17 +579,17 @@ let pass_logic_cast exn typ trm =
...
@@ -581,17 +579,17 @@ let pass_logic_cast exn typ trm =
match
Logic_utils
.
unroll_type
typ
,
Logic_utils
.
unroll_type
trm
.
term_type
with
match
Logic_utils
.
unroll_type
typ
,
Logic_utils
.
unroll_type
trm
.
term_type
with
|
Linteger
,
Ctype
(
TInt
_
|
TEnum
_
)
->
()
(* Always inclusion *)
|
Linteger
,
Ctype
(
TInt
_
|
TEnum
_
)
->
()
(* Always inclusion *)
|
Ctype
(
TInt
_
|
TEnum
_
as
typ
)
,
Ctype
(
TInt
_
|
TEnum
_
as
typeoftrm
)
->
|
Ctype
(
TInt
_
|
TEnum
_
as
typ
)
,
Ctype
(
TInt
_
|
TEnum
_
as
typeoftrm
)
->
let
sztyp
=
sizeof
typ
in
let
sztyp
=
Bit_utils
.
sizeof
typ
in
let
szexpr
=
sizeof
typeoftrm
in
let
szexpr
=
Bit_utils
.
sizeof
typeoftrm
in
let
styp
,
sexpr
=
let
styp
,
sexpr
=
match
sztyp
,
szexpr
with
match
sztyp
,
szexpr
with
|
Int_Base
.
Value
styp
,
Int_Base
.
Value
sexpr
->
styp
,
sexpr
|
Int_Base
.
Value
styp
,
Int_Base
.
Value
sexpr
->
styp
,
sexpr
|
_
->
raise
exn
|
_
->
raise
exn
in
in
let
sityp
=
is_signed_int_enum_pointer
typ
in
let
sityp
=
Bit_utils
.
is_signed_int_enum_pointer
typ
in
let
sisexpr
=
is_signed_int_enum_pointer
typeoftrm
in
let
sisexpr
=
Bit_utils
.
is_signed_int_enum_pointer
typeoftrm
in
if
(
Int
.
ge
styp
sexpr
&&
sityp
=
sisexpr
)
(* larger, same signedness *)
if
(
Int
eger
.
ge
styp
sexpr
&&
sityp
=
sisexpr
)
(* larger, same signedness *)
||
(
Int
.
gt
styp
sexpr
&&
sityp
)
(* strictly larger and signed *)
||
(
Int
eger
.
gt
styp
sexpr
&&
sityp
)
(* strictly larger and signed *)
then
()
then
()
else
raise
exn
else
raise
exn
...
@@ -626,7 +624,7 @@ let constraint_trange idx size_arr =
...
@@ -626,7 +624,7 @@ let constraint_trange idx size_arr =
in
in
let
up
=
match
up
with
(* constrained r.h.s *)
let
up
=
match
up
with
(* constrained r.h.s *)
|
Some
_
->
up
|
Some
_
->
up
|
None
->
Some
(
Logic_const
.
tint
~
loc
(
Int
.
pred
size
))
|
None
->
Some
(
Logic_const
.
tint
~
loc
(
Int
eger
.
pred
size
))
in
in
Logic_const
.
trange
~
loc
(
low
,
up
)
Logic_const
.
trange
~
loc
(
low
,
up
)
end
end
...
@@ -721,8 +719,8 @@ let inline logic_info =
...
@@ -721,8 +719,8 @@ let inline logic_info =
and the \Positive and \Negative constructors (handled in eval_term). They can
and the \Positive and \Negative constructors (handled in eval_term). They can
only be compared through equality and disequality; no other operation exists
only be compared through equality and disequality; no other operation exists
on this type, so our interpretation remains correct. *)
on this type, so our interpretation remains correct. *)
let
positive_cvalue
=
Cvalue
.
V
.
inject_int
Int
.
one
let
positive_cvalue
=
Cvalue
.
V
.
inject_int
Int
eger
.
one
let
negative_cvalue
=
Cvalue
.
V
.
inject_int
Int
.
minus_one
let
negative_cvalue
=
Cvalue
.
V
.
inject_int
Int
eger
.
minus_one
let
is_true
=
function
let
is_true
=
function
|
`True
|
`TrueReduced
_
->
true
|
`True
|
`TrueReduced
_
->
true
...
@@ -799,7 +797,7 @@ let eval_logic_charlen wrapper env v ldeps =
...
@@ -799,7 +797,7 @@ let eval_logic_charlen wrapper env v ldeps =
let
eover
=
let
eover
=
let
v
,
alarms
=
apply_logic_builtin
wrapper
env
[
v
]
in
let
v
,
alarms
=
apply_logic_builtin
wrapper
env
[
v
]
in
if
alarms
&&
not
(
Cvalue
.
V
.
is_bottom
v
)
if
alarms
&&
not
(
Cvalue
.
V
.
is_bottom
v
)
then
Cvalue
.
V
.
inject_ival
(
Ival
.
inject_range
(
Some
Int
.
minus_one
)
None
)
then
Cvalue
.
V
.
inject_ival
(
Ival
.
inject_range
(
Some
Int
eger
.
minus_one
)
None
)
else
v
else
v
in
in
let
eunder
=
under_from_over
eover
in
let
eunder
=
under_from_over
eover
in
...
@@ -1253,11 +1251,11 @@ let rec eval_term ~alarm_mode env t =
...
@@ -1253,11 +1251,11 @@ let rec eval_term ~alarm_mode env t =
frontiers are always 0 or 8*k-1 (because validity is in bits and
frontiers are always 0 or 8*k-1 (because validity is in bits and
starts on zero), so we add 1 everywhere, then divide by eight. *)
starts on zero), so we add 1 everywhere, then divide by eight. *)
let
convert
start_bits
end_bits
=
let
convert
start_bits
end_bits
=
let
congr_succ
i
=
Int
.(
equal
zero
(
e_rem
(
succ
i
)
eight
))
in
let
congr_succ
i
=
Int
eger
.(
equal
zero
(
e_rem
(
succ
i
)
eight
))
in
let
congr_or_zero
i
=
Int
.(
equal
zero
i
||
congr_succ
i
)
in
let
congr_or_zero
i
=
Int
eger
.(
equal
zero
i
||
congr_succ
i
)
in
assert
(
congr_or_zero
start_bits
||
congr_or_zero
end_bits
);
assert
(
congr_or_zero
start_bits
||
congr_or_zero
end_bits
);
let
start_bytes
=
Int
.(
e_div
(
Int
.
succ
start_bits
)
eight
)
in
let
start_bytes
=
Int
eger
.(
e_div
(
Int
eger
.
succ
start_bits
)
eight
)
in
let
end_bytes
=
Int
.(
e_div
(
Int
.
succ
end_bits
)
eight
)
in
let
end_bytes
=
Int
eger
.(
e_div
(
Int
eger
.
succ
end_bits
)
eight
)
in
Ival
.
inject_range
(
Some
start_bytes
)
(
Some
end_bytes
)
Ival
.
inject_range
(
Some
start_bytes
)
(
Some
end_bytes
)
in
in
match
Base
.
validity
b
with
match
Base
.
validity
b
with
...
@@ -1445,7 +1443,8 @@ and eval_known_logic_function ~alarm_mode env li labels args =
...
@@ -1445,7 +1443,8 @@ and eval_known_logic_function ~alarm_mode env li labels args =
|
(
"
\\
min"
|
"
\\
max"
)
,
Some
typ
,
_
,
t1
::
t2
::
tail_args
->
|
(
"
\\
min"
|
"
\\
max"
)
,
Some
typ
,
_
,
t1
::
t2
::
tail_args
->
begin
begin
let
comp
=
if
lvi
.
lv_name
=
"
\\
min"
then
Comp
.
Le
else
Comp
.
Ge
in
let
min
=
lvi
.
lv_name
=
"
\\
min"
in
let
comp
=
Abstract_interp
.
Comp
.(
if
min
then
Le
else
Ge
)
in
let
backward
=
let
backward
=
match
typ
with
match
typ
with
|
Linteger
->
Cvalue
.
V
.
backward_comp_int_left
comp
|
Linteger
->
Cvalue
.
V
.
backward_comp_int_left
comp
...
@@ -1919,7 +1918,7 @@ and reduce_by_valid env positive access (tset: term) =
...
@@ -1919,7 +1918,7 @@ and reduce_by_valid env positive access (tset: term) =
in
in
let
li
=
if
op
=
PlusPI
then
li
else
Ival
.
neg_int
li
in
let
li
=
if
op
=
PlusPI
then
li
else
Ival
.
neg_int
li
in
let
typ_p
=
Cil
.
typeOf_pointed
rtlv
.
etype
in
let
typ_p
=
Cil
.
typeOf_pointed
rtlv
.
etype
in
let
sbits
=
Int
.
of_int
(
Cil
.
bitsSizeOf
typ_p
)
in
let
sbits
=
Int
eger
.
of_int
(
Cil
.
bitsSizeOf
typ_p
)
in
(* Compute the offsets expected by [aux], which are [i *
(* Compute the offsets expected by [aux], which are [i *
8 * sizeof( *tlv)] *)
8 * sizeof( *tlv)] *)
let
li
=
Ival
.
scale
sbits
li
in
let
li
=
Ival
.
scale
sbits
li
in
...
@@ -2550,6 +2549,7 @@ and eval_predicate env pred =
...
@@ -2550,6 +2549,7 @@ and eval_predicate env pred =
(* Logic predicates. Update the list known_predicates above if you
(* Logic predicates. Update the list known_predicates above if you
add something here. *)
add something here. *)
and
eval_known_papp
env
li
_labels
args
=
and
eval_known_papp
env
li
_labels
args
=
let
open
Abstract_interp
in
let
unary_float
unary_fun
arg
=
let
unary_float
unary_fun
arg
=
try
try
let
eval_result
=
eval_term
~
alarm_mode
env
arg
in
let
eval_result
=
eval_term
~
alarm_mode
env
arg
in
...
@@ -2692,12 +2692,12 @@ let predicate_deps env pred =
...
@@ -2692,12 +2692,12 @@ let predicate_deps env pred =
empty_logic_deps
args
empty_logic_deps
args
else
else
match
Inline
.
inline_predicate
~
inline
~
current
:
env
.
e_cur
p
with
match
Inline
.
inline_predicate
~
inline
~
current
:
env
.
e_cur
p
with
|
None
->
unsupported
(
Format
.
asprintf
"%a"
Pr
edica
te
.
p
retty
p
)
|
None
->
unsupported
(
Format
.
asprintf
"%a"
Pr
in
te
r
.
p
p_predicate
p
)
|
Some
p'
->
do_eval
env
p'
|
Some
p'
->
do_eval
env
p'
end
end
|
Pfresh
_
|
Pallocable
_
|
Pfreeable
_
|
Pfresh
_
|
Pallocable
_
|
Pfreeable
_
->
unsupported
(
Format
.
asprintf
"%a"
Pr
edica
te
.
p
retty
p
)
->
unsupported
(
Format
.
asprintf
"%a"
Pr
in
te
r
.
p
p_predicate
p
)
in
in
try
Some
(
do_eval
env
pred
)
try
Some
(
do_eval
env
pred
)
with
LogicEvalError
_
->
None
with
LogicEvalError
_
->
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment