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
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
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
Charles Southerland
frama-c
Commits
40c243f9
Commit
40c243f9
authored
4 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[wp] refactor contract to prepare stmt
parent
6333b720
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/plugins/wp/cfgAnnot.ml
+38
-38
38 additions, 38 deletions
src/plugins/wp/cfgAnnot.ml
src/plugins/wp/cfgAnnot.mli
+7
-7
7 additions, 7 deletions
src/plugins/wp/cfgAnnot.mli
src/plugins/wp/cfgCalculus.ml
+8
-9
8 additions, 9 deletions
src/plugins/wp/cfgCalculus.ml
with
53 additions
and
54 deletions
src/plugins/wp/cfgAnnot.ml
+
38
−
38
View file @
40c243f9
...
@@ -180,7 +180,37 @@ let get_disjoint_behaviors kf =
...
@@ -180,7 +180,37 @@ let get_disjoint_behaviors kf =
)
spec
.
spec_disjoint_behaviors
)
spec
.
spec_disjoint_behaviors
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* --- Called Contract --- *)
(* --- Contracts --- *)
(* -------------------------------------------------------------------------- *)
type
contract
=
{
contract_pre
:
WpPropId
.
pred_info
list
;
contract_post
:
WpPropId
.
pred_info
list
;
contract_exit
:
WpPropId
.
pred_info
list
;
contract_smoke
:
WpPropId
.
pred_info
list
;
contract_assigns
:
Cil_types
.
assigns
;
}
let
assigns_upper_bound
behaviors
=
let
collect_assigns
(
def
,
assigns
)
bhv
=
(* Default behavior prevails *)
if
Cil
.
is_default_behavior
bhv
then
Some
bhv
.
b_assigns
,
None
else
if
Option
.
is_some
def
then
def
,
None
else
begin
(* Note that here, def is None *)
match
assigns
,
bhv
.
b_assigns
with
|
None
,
a
->
None
,
Some
a
|
Some
WritesAny
,
_
|
Some
_
,
WritesAny
->
None
,
Some
WritesAny
|
Some
(
Writes
a
)
,
Writes
b
->
None
,
Some
(
Writes
(
a
@
b
))
end
in
match
List
.
fold_left
collect_assigns
(
None
,
None
)
behaviors
with
|
Some
a
,
_
->
a
(* default behavior first *)
|
_
,
Some
a
->
a
(* else combined behaviors *)
|
_
->
WritesAny
(* -------------------------------------------------------------------------- *)
(* --- Call Contracts --- *)
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(*TODO: put it in Status_by_call ? *)
(*TODO: put it in Status_by_call ? *)
...
@@ -199,42 +229,16 @@ let setup_preconditions kf =
...
@@ -199,42 +229,16 @@ let setup_preconditions kf =
Statuses_by_call
.
setup_all_preconditions_proxies
kf
;
Statuses_by_call
.
setup_all_preconditions_proxies
kf
;
end
end
type
call_contract
=
{
call_pre
:
WpPropId
.
pred_info
list
;
call_post
:
WpPropId
.
pred_info
list
;
call_exit
:
WpPropId
.
pred_info
list
;
call_smoke
:
WpPropId
.
pred_info
list
;
call_assigns
:
Cil_types
.
assigns
;
}
let
get_precond_at
kf
stmt
(
id
,
p
)
=
let
get_precond_at
kf
stmt
(
id
,
p
)
=
let
pi
=
WpPropId
.
property_of_id
id
in
let
pi
=
WpPropId
.
property_of_id
id
in
let
pi_at
=
Statuses_by_call
.
precondition_at_call
kf
pi
stmt
in
let
pi_at
=
Statuses_by_call
.
precondition_at_call
kf
pi
stmt
in
let
id_at
=
WpPropId
.
mk_call_pre_id
kf
stmt
pi
pi_at
in
let
id_at
=
WpPropId
.
mk_call_pre_id
kf
stmt
pi
pi_at
in
id_at
,
p
id_at
,
p
let
assigns_upper_bound
behaviors
=
let
collect_assigns
(
def
,
assigns
)
bhv
=
(* Default behavior prevails *)
if
Cil
.
is_default_behavior
bhv
then
Some
bhv
.
b_assigns
,
None
else
if
Option
.
is_some
def
then
def
,
None
else
begin
(* Note that here, def is None *)
match
assigns
,
bhv
.
b_assigns
with
|
None
,
a
->
None
,
Some
a
|
Some
WritesAny
,
_
|
Some
_
,
WritesAny
->
None
,
Some
WritesAny
|
Some
(
Writes
a
)
,
Writes
b
->
None
,
Some
(
Writes
(
a
@
b
))
end
in
match
List
.
fold_left
collect_assigns
(
None
,
None
)
behaviors
with
|
Some
a
,
_
->
a
(* default behavior first *)
|
_
,
Some
a
->
a
(* else combined behaviors *)
|
_
->
WritesAny
module
CallContract
=
WpContext
.
StaticGenerator
(
Kernel_function
)
module
CallContract
=
WpContext
.
StaticGenerator
(
Kernel_function
)
(
struct
(
struct
type
key
=
kernel_function
type
key
=
kernel_function
type
data
=
call_
contract
type
data
=
contract
let
name
=
"Wp.CfgAnnot.CallContract"
let
name
=
"Wp.CfgAnnot.CallContract"
let
compile
kf
=
let
compile
kf
=
let
cpre
:
WpPropId
.
pred_info
list
ref
=
ref
[]
in
let
cpre
:
WpPropId
.
pred_info
list
ref
=
ref
[]
in
...
@@ -255,11 +259,11 @@ module CallContract = WpContext.StaticGenerator(Kernel_function)
...
@@ -255,11 +259,11 @@ module CallContract = WpContext.StaticGenerator(Kernel_function)
)
bhv
.
b_post_cond
;
)
bhv
.
b_post_cond
;
end
behaviors
;
end
behaviors
;
{
{
c
all
_pre
=
List
.
rev
!
cpre
;
c
ontract
_pre
=
List
.
rev
!
cpre
;
c
all
_post
=
List
.
rev
!
cpost
;
c
ontract
_post
=
List
.
rev
!
cpost
;
c
all
_exit
=
List
.
rev
!
cexit
;
c
ontract
_exit
=
List
.
rev
!
cexit
;
c
all
_smoke
=
[]
;
c
ontract
_smoke
=
[]
;
c
all
_assigns
=
assigns_upper_bound
behaviors
c
ontract
_assigns
=
assigns_upper_bound
behaviors
}
}
end
)
end
)
...
@@ -269,11 +273,7 @@ let get_call_contract ?smoking kf =
...
@@ -269,11 +273,7 @@ let get_call_contract ?smoking kf =
|
None
->
cc
|
None
->
cc
|
Some
s
->
|
Some
s
->
let
g
=
smoke
kf
~
id
:
"dead_call"
~
unreachable
:
s
()
in
let
g
=
smoke
kf
~
id
:
"dead_call"
~
unreachable
:
s
()
in
{
cc
with
{
cc
with
contract_smoke
=
[
g
]
}
call_smoke
=
[
g
]
;
call_post
=
cc
.
call_post
;
call_exit
=
cc
.
call_exit
;
}
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* --- Code Assertions --- *)
(* --- Code Assertions --- *)
...
...
This diff is collapsed.
Click to expand it.
src/plugins/wp/cfgAnnot.mli
+
7
−
7
View file @
40c243f9
...
@@ -91,16 +91,16 @@ val get_loop_contract : ?smoking:bool ->
...
@@ -91,16 +91,16 @@ val get_loop_contract : ?smoking:bool ->
(* --- Property Accessors : Call Contracts --- *)
(* --- Property Accessors : Call Contracts --- *)
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
type
call_
contract
=
{
type
contract
=
{
c
all
_pre
:
pred_info
list
;
c
ontract
_pre
:
pred_info
list
;
c
all
_post
:
pred_info
list
;
c
ontract
_post
:
pred_info
list
;
c
all
_exit
:
pred_info
list
;
c
ontract
_exit
:
pred_info
list
;
c
all
_smoke
:
pred_info
list
;
c
ontract
_smoke
:
pred_info
list
;
c
all
_assigns
:
assigns
;
c
ontract
_assigns
:
assigns
;
}
}
val
get_precond_at
:
kernel_function
->
stmt
->
pred_info
->
pred_info
val
get_precond_at
:
kernel_function
->
stmt
->
pred_info
->
pred_info
val
get_call_contract
:
?
smoking
:
stmt
->
kernel_function
->
call_
contract
val
get_call_contract
:
?
smoking
:
stmt
->
kernel_function
->
contract
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* --- Clear Tablesnts --- *)
(* --- Clear Tablesnts --- *)
...
...
This diff is collapsed.
Click to expand it.
src/plugins/wp/cfgCalculus.ml
+
8
−
9
View file @
40c243f9
...
@@ -99,8 +99,7 @@ let is_active_mode ~mode ~goal (p: Property.t) =
...
@@ -99,8 +99,7 @@ let is_active_mode ~mode ~goal (p: Property.t) =
|
IPDecrease
{
id_ca
=
Some
ca
}
->
is_selected_ca
mode
~
goal
ca
|
IPDecrease
{
id_ca
=
Some
ca
}
->
is_selected_ca
mode
~
goal
ca
|
IPComplete
_
|
IPDisjoint
_
->
is_default_bhv
mode
|
IPComplete
_
|
IPDisjoint
_
->
is_default_bhv
mode
|
IPOther
_
->
true
|
IPOther
_
->
true
|
IPFrom
_
|
IPGlobalInvariant
_
|
IPTypeInvariant
_
->
|
IPFrom
_
|
IPGlobalInvariant
_
|
IPTypeInvariant
_
(*TODO: is it in pass or not ? *)
assert
false
|
IPAxiomatic
_
|
IPAxiom
_
|
IPLemma
_
|
IPAxiomatic
_
|
IPAxiom
_
|
IPLemma
_
|
IPExtended
_
|
IPBehavior
_
|
IPExtended
_
|
IPBehavior
_
|
IPReachable
_
|
IPPropertyInstance
_
|
IPReachable
_
|
IPPropertyInstance
_
...
@@ -304,13 +303,13 @@ struct
...
@@ -304,13 +303,13 @@ struct
WpLog
.
SmokeDeadcall
.
get
()
WpLog
.
SmokeDeadcall
.
get
()
then
Some
s
else
None
in
then
Some
s
else
None
in
let
c
=
CfgAnnot
.
get_call_contract
?
smoking
kf
in
let
c
=
CfgAnnot
.
get_call_contract
?
smoking
kf
in
let
p_post
=
List
.
fold_right
(
prove_property
env
)
c
.
c
all
_smoke
wr
in
let
p_post
=
List
.
fold_right
(
prove_property
env
)
c
.
c
ontract
_smoke
wr
in
let
p_exit
=
List
.
fold_right
(
prove_property
env
)
c
.
c
all
_smoke
env
.
wk
in
let
p_exit
=
List
.
fold_right
(
prove_property
env
)
c
.
c
ontract
_smoke
env
.
wk
in
let
w_call
=
W
.
call
env
.
we
s
r
kf
es
let
w_call
=
W
.
call
env
.
we
s
r
kf
es
~
pre
:
c
.
c
all
_pre
~
pre
:
c
.
c
ontract
_pre
~
post
:
c
.
c
all
_post
~
post
:
c
.
c
ontract
_post
~
pexit
:
c
.
c
all
_exit
~
pexit
:
c
.
c
ontract
_exit
~
assigns
:
c
.
c
all
_assigns
~
assigns
:
c
.
c
ontract
_assigns
~
p_post
~
p_exit
in
~
p_post
~
p_exit
in
if
is_default_bhv
env
.
mode
then
if
is_default_bhv
env
.
mode
then
let
pre
=
let
pre
=
...
@@ -318,7 +317,7 @@ struct
...
@@ -318,7 +317,7 @@ struct
if
is_selected_callpre
env
p
then
if
is_selected_callpre
env
p
then
Some
(
CfgAnnot
.
get_precond_at
kf
s
p
)
Some
(
CfgAnnot
.
get_precond_at
kf
s
p
)
else
None
else
None
)
c
.
c
all
_pre
)
c
.
c
ontract
_pre
in
W
.
call_goal_precond
env
.
we
s
kf
es
~
pre
w_call
in
W
.
call_goal_precond
env
.
we
s
kf
es
~
pre
w_call
else
w_call
else
w_call
...
...
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