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
09eca65f
Commit
09eca65f
authored
4 years ago
by
Allan Blanchard
Browse files
Options
Downloads
Patches
Plain Diff
[wp] Use OcamlGraph for reachability
parent
bb1bc134
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/wp/cfgInfos.ml
+18
-43
18 additions, 43 deletions
src/plugins/wp/cfgInfos.ml
with
18 additions
and
43 deletions
src/plugins/wp/cfgInfos.ml
+
18
−
43
View file @
09eca65f
...
@@ -22,19 +22,20 @@
...
@@ -22,19 +22,20 @@
module
Cfg
=
Interpreted_automata
module
Cfg
=
Interpreted_automata
module
Fset
=
Kernel_function
.
Set
module
Fset
=
Kernel_function
.
Set
module
Vhash
=
Cfg
.
Vertex
.
Hashtbl
module
Shash
=
Cil_datatype
.
Stmt
.
Hashtbl
module
Shash
=
Cil_datatype
.
Stmt
.
Hashtbl
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* --- Compute Kernel-Function & CFG Infos for WP --- *)
(* --- Compute Kernel-Function & CFG Infos for WP --- *)
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
module
Reachability
=
Graph
.
Path
.
Check
(
Cfg
.
G
)
type
t
=
{
type
t
=
{
cfg
:
Cfg
.
automaton
option
;
cfg
:
Cfg
.
automaton
option
;
reachability
:
Reachability
.
path_checker
option
;
mutable
annots
:
bool
;
(* has goals to prove *)
mutable
annots
:
bool
;
(* has goals to prove *)
mutable
doomed
:
WpPropId
.
prop_id
Bag
.
t
;
mutable
doomed
:
WpPropId
.
prop_id
Bag
.
t
;
mutable
calls
:
Kernel_function
.
Set
.
t
;
mutable
calls
:
Kernel_function
.
Set
.
t
;
unreachable
:
bool
option
Vhash
.
t
;
}
}
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
...
@@ -46,35 +47,10 @@ let calls infos = infos.calls
...
@@ -46,35 +47,10 @@ let calls infos = infos.calls
let
annots
infos
=
infos
.
annots
let
annots
infos
=
infos
.
annots
let
doomed
infos
=
infos
.
doomed
let
doomed
infos
=
infos
.
doomed
(* -------------------------------------------------------------------------- *)
(* --- Reachability Analyses --- *)
(* -------------------------------------------------------------------------- *)
let
fixpoint
h
f
=
let
rec
phi
v
=
try
Vhash
.
find
h
v
with
Not_found
->
Vhash
.
add
h
v
None
;
let
r
=
f
phi
v
in
if
Option
.
is_none
r
then
Vhash
.
remove
h
v
else
Vhash
.
replace
h
v
r
;
r
in
phi
let
unreachable
infos
v
=
let
unreachable
infos
v
=
let
pred
=
Cfg
.
G
.
pred
(
Option
.
get
infos
.
cfg
)
.
graph
in
let
reachability
=
Option
.
get
infos
.
reachability
in
let
do_fixpoint
=
fixpoint
infos
.
unreachable
let
entry
=
(
Option
.
get
infos
.
cfg
)
.
entry_point
in
begin
fun
phi
v
->
not
@@
Reachability
.
check_path
reachability
entry
v
match
List
.
map
phi
(
pred
v
)
with
|
l
when
List
.
exists
(
fun
x
->
x
=
Some
false
)
l
->
Some
false
|
l
when
List
.
for_all
(
fun
x
->
x
=
Some
true
)
l
->
Some
true
|
_
->
None
end
in
match
do_fixpoint
v
with
|
Some
x
->
x
|
None
->
Vhash
.
add
infos
.
unreachable
v
(
Some
false
)
;
false
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* --- Selected Properties --- *)
(* --- Selected Properties --- *)
...
@@ -94,11 +70,11 @@ let selected_assigns ~prop = function
...
@@ -94,11 +70,11 @@ let selected_assigns ~prop = function
|
Cil_types
.
WritesAny
->
false
|
Cil_types
.
WritesAny
->
false
|
Writes
_
when
prop
=
[]
->
true
|
Writes
_
when
prop
=
[]
->
true
|
Writes
l
->
|
Writes
l
->
let
collect_names
l
(
t
,
_
)
=
let
collect_names
l
(
t
,
_
)
=
WpPropId
.
ident_names
t
.
Cil_types
.
it_content
.
term_name
@
l
WpPropId
.
ident_names
t
.
Cil_types
.
it_content
.
term_name
@
l
in
in
let
names
=
List
.
fold_left
collect_names
[
"@assigns"
]
l
in
let
names
=
List
.
fold_left
collect_names
[
"@assigns"
]
l
in
WpPropId
.
are_selected_names
prop
names
WpPropId
.
are_selected_names
prop
names
let
selected_allocates
~
prop
=
function
let
selected_allocates
~
prop
=
function
|
Cil_types
.
FreeAllocAny
->
false
|
Cil_types
.
FreeAllocAny
->
false
...
@@ -215,16 +191,18 @@ let loop_contract_pids kf stmt =
...
@@ -215,16 +191,18 @@ let loop_contract_pids kf stmt =
|
_
->
[]
|
_
->
[]
let
compile
Key
.{
kf
;
bhv
;
prop
}
=
let
compile
Key
.{
kf
;
bhv
;
prop
}
=
let
cfg
=
let
cfg
,
reachability
=
if
Kernel_function
.
has_definition
kf
then
Some
(
Cfg
.
get_automaton
kf
)
if
Kernel_function
.
has_definition
kf
then
else
None
let
cfg
=
Cfg
.
get_automaton
kf
in
Some
cfg
,
Some
(
Reachability
.
create
cfg
.
graph
)
else
None
,
None
in
in
let
infos
=
{
let
infos
=
{
cfg
;
cfg
;
annots
=
false
;
annots
=
false
;
doomed
=
Bag
.
empty
;
doomed
=
Bag
.
empty
;
calls
=
Fset
.
empty
;
calls
=
Fset
.
empty
;
un
reachab
le
=
Vhash
.
create
32
;
reachab
ility
}
in
}
in
let
behaviors
=
Annotations
.
behaviors
kf
in
let
behaviors
=
Annotations
.
behaviors
kf
in
if
WpStrategy
.
is_main_init
kf
then
if
WpStrategy
.
is_main_init
kf
then
...
@@ -232,9 +210,6 @@ let compile Key.{ kf ; bhv ; prop } =
...
@@ -232,9 +210,6 @@ let compile Key.{ kf ; bhv ; prop } =
if
Kernel_function
.
has_definition
kf
then
begin
if
Kernel_function
.
has_definition
kf
then
begin
let
cfg
=
Option
.
get
cfg
in
let
cfg
=
Option
.
get
cfg
in
(* Root Reachability *)
let
v0
=
cfg
.
entry_point
in
Vhash
.
add
infos
.
unreachable
v0
(
Some
false
)
;
(* Spec Iteration *)
(* Spec Iteration *)
if
selected_disjoint_complete
kf
~
bhv
~
prop
||
if
selected_disjoint_complete
kf
~
bhv
~
prop
||
(
List
.
exists
(
selected_bhv
~
bhv
~
prop
)
behaviors
)
(
List
.
exists
(
selected_bhv
~
bhv
~
prop
)
behaviors
)
...
...
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