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
a2143efb
Commit
a2143efb
authored
5 years ago
by
David Bühler
Browse files
Options
Downloads
Patches
Plain Diff
[Eva] Ival: new function complement_int.
parent
d2663a1f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/kernel_services/abstract_interp/ival.ml
+36
-0
36 additions, 0 deletions
src/kernel_services/abstract_interp/ival.ml
src/kernel_services/abstract_interp/ival.mli
+3
-0
3 additions, 0 deletions
src/kernel_services/abstract_interp/ival.mli
with
39 additions
and
0 deletions
src/kernel_services/abstract_interp/ival.ml
+
36
−
0
View file @
a2143efb
...
@@ -1161,6 +1161,42 @@ let join v1 v2 =
...
@@ -1161,6 +1161,42 @@ let join v1 v2 =
pretty v1 pretty v2 pretty result; *)
pretty v1 pretty v2 pretty result; *)
result
result
let
complement_int_under
~
size
~
signed
i
=
let
e
=
Int
.
two_power_of_int
(
if
signed
then
size
-
1
else
size
)
in
let
b
=
if
signed
then
Int
.
neg
e
else
Int
.
zero
in
let
e
=
Int
.
pred
e
in
let
inject_range
min
max
=
`Value
(
inject_range
(
Some
min
)
(
Some
max
))
in
match
i
with
|
Float
_
->
`Bottom
|
Set
[
||
]
->
inject_range
b
e
|
Set
set
->
let
l
=
Array
.
length
set
in
let
array
=
Array
.
make
(
l
+
2
)
Int
.
zero
in
array
.
(
0
)
<-
b
;
Array
.
blit
set
0
array
1
l
;
array
.
(
l
+
1
)
<-
e
;
let
index
=
ref
(
-
1
)
in
let
max_delta
=
ref
Int
.
zero
in
for
i
=
0
to
l
do
let
delta
=
Int
.
sub
array
.
(
i
+
1
)
array
.
(
i
)
in
if
Int
.
gt
delta
!
max_delta
then
begin
index
:=
i
;
max_delta
:=
delta
end
done
;
inject_range
array
.
(
!
index
)
array
.
(
!
index
+
1
)
|
Top
(
min
,
max
,
_rem
,
_modu
)
->
match
min
,
max
with
|
None
,
None
->
`Bottom
|
Some
min
,
None
->
inject_range
b
(
Int
.
pred
min
)
|
None
,
Some
max
->
inject_range
(
Int
.
succ
max
)
e
|
Some
min
,
Some
max
->
let
delta_min
=
Int
.
sub
min
b
in
let
delta_max
=
Int
.
sub
e
max
in
if
Int
.
le
delta_min
delta_max
then
inject_range
(
Int
.
succ
max
)
e
else
inject_range
b
(
Int
.
pred
min
)
let
fold_int
f
v
acc
=
let
fold_int
f
v
acc
=
match
v
with
match
v
with
Top
(
None
,_,_,_
)
|
Top
(
_
,
None
,_,_
)
|
Float
_
->
Top
(
None
,_,_,_
)
|
Top
(
_
,
None
,_,_
)
|
Float
_
->
...
...
This diff is collapsed.
Click to expand it.
src/kernel_services/abstract_interp/ival.mli
+
3
−
0
View file @
a2143efb
...
@@ -319,6 +319,9 @@ val reinterpret_as_int: size:Integer.t -> signed:bool -> t -> t
...
@@ -319,6 +319,9 @@ val reinterpret_as_int: size:Integer.t -> signed:bool -> t -> t
(** Bitwise reinterpretation of the given value, of size [size], as an integer
(** Bitwise reinterpretation of the given value, of size [size], as an integer
of the given signedness (and size). *)
of the given signedness (and size). *)
val
complement_int_under
:
size
:
int
->
signed
:
bool
->
t
->
t
Bottom
.
or_bottom
(** Returns an under-approximation of the integers of the given size and
signedness that are *not* represented by the given ival. *)
val
pretty_debug
:
Format
.
formatter
->
t
->
unit
val
pretty_debug
:
Format
.
formatter
->
t
->
unit
...
...
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