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
fae4619a
Commit
fae4619a
authored
6 years ago
by
Patrick Baudin
Browse files
Options
Downloads
Patches
Plain Diff
[Wp] expose CIL invariants about initializer
parent
e5d1c85a
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/CodeSemantics.ml
+24
-24
24 additions, 24 deletions
src/plugins/wp/CodeSemantics.ml
with
24 additions
and
24 deletions
src/plugins/wp/CodeSemantics.ml
+
24
−
24
View file @
fae4619a
...
@@ -497,20 +497,20 @@ struct
...
@@ -497,20 +497,20 @@ struct
let
delayed
=
let
delayed
=
match
len
with
(* number of required elements *)
match
len
with
(* number of required elements *)
|
Some
{
enode
=
(
Const
CInt64
(
size
,_,_
))}
->
|
Some
{
enode
=
(
Const
CInt64
(
size
,_,_
))}
->
Some
(
size
,
None
)
(
size
,
None
)
|
_
->
None
|
_
->
(* CIL invariant broken. *)
WpLog
.
fatal
"CIL invariant broken: unknown initialized array size"
in
in
let
make_quant
acc
=
function
let
make_quant
acc
=
function
(* adds delayed initializations from info about
(* adds delayed initializations from info about
the last consecutive indices having
the last consecutive indices having
the same value, but that have not yet initialized. *)
the same value, but that have not yet initialized. *)
|
None
->
acc
(* nothing was delayed *)
|
(
_
,
None
)
->
acc
(* nothing was delayed *)
|
Some
(
_
,
None
)
->
acc
(* nothing was delayed *)
|
(
il
,
Some
(
i0
,_,
exp
))
when
Integer
.
lt
il
i0
->
|
Some
(
il
,
Some
(
i0
,_,
exp
))
when
Integer
.
lt
il
i0
->
(* Added pred: \forall i \in [il .. i0] ; t[i]==exp *)
(* Added pred: \forall i \in [il .. i0] ; t[i]==exp *)
let
i2
=
Integer
.
succ
i0
in
let
i2
=
Integer
.
succ
i0
in
init_range
~
sigma
lv
ty
il
i2
(
Some
exp
)
::
acc
init_range
~
sigma
lv
ty
il
i2
(
Some
exp
)
::
acc
|
Some
(
_il
,
Some
(
_i0
,
off
,
exp
))
->
|
(
_il
,
Some
(
_i0
,
off
,
exp
))
->
(* case [_il=_i0], so uses [off] corresponding to [_i0]
(* case [_il=_i0], so uses [off] corresponding to [_i0]
Added pred: t[i]==exp*)
Added pred: t[i]==exp*)
let
lv
=
Cil
.
addOffsetLval
off
lv
in
let
lv
=
Cil
.
addOffsetLval
off
lv
in
...
@@ -518,12 +518,11 @@ struct
...
@@ -518,12 +518,11 @@ struct
in
in
let
add_missing_indices
acc
i0
=
function
let
add_missing_indices
acc
i0
=
function
(* adds eventual default value for missing indices. *)
(* adds eventual default value for missing indices. *)
|
Some
(
i1
,
_
)
->
|
(
i1
,
_
)
->
if
Integer
.
ge
i0
i1
then
(* no hole *)
acc
if
Integer
.
ge
i0
i1
then
(* no hole *)
acc
else
(* defaults values
else
(* defaults values
Added pred: \forall i \in [i0 .. i1[ ; t[i]==default *)
Added pred: \forall i \in [i0 .. i1[ ; t[i]==default *)
init_range
~
sigma
lv
ty
i0
i1
None
::
acc
init_range
~
sigma
lv
ty
i0
i1
None
::
acc
|
_
->
(* last bound is unknown. *)
acc
in
in
let
acc
,
delayed
=
let
acc
,
delayed
=
List
.
fold_left
List
.
fold_left
...
@@ -532,35 +531,36 @@ struct
...
@@ -532,35 +531,36 @@ struct
let
idx
,
acc
=
match
off
with
let
idx
,
acc
=
match
off
with
|
Index
({
enode
=
Const
CInt64
(
idx
,_,_
)}
,
_
)
->
|
Index
({
enode
=
Const
CInt64
(
idx
,_,_
)}
,
_
)
->
(
match
delayed
with
(
match
delayed
with
|
Some
(
iprev
,
_
)
when
Integer
.
lt
iprev
idx
->
|
(
iprev
,
_
)
when
Integer
.
lt
iprev
idx
->
(* otherwice, an algo with a 2sd pass is
(* CIL invariant broken.
required for introducing default values *)
without that invariant, an algo with a 2sd pass
WpLog
.
fatal
"Unordered initializer"
;
is required for introducing default values *)
WpLog
.
fatal
"CIL invariant broken: unordered initializer"
;
|
_
->
()
)
;
|
_
->
()
)
;
Some
(
idx
,
None
)
,
idx
,
(* adds default values for missing indices *)
(* adds default values for missing indices *)
add_missing_indices
acc
(
Integer
.
succ
idx
)
delayed
add_missing_indices
acc
(
Integer
.
succ
idx
)
delayed
|
_
->
None
,
acc
|
_
->
(* CIL invariant broken. *)
WpLog
.
fatal
"CIL invariant broken: unknown initialized index"
in
in
match
idx
,
off
,
init
with
(* only simple init can be delayed *)
match
off
,
init
with
(* only simple init can be delayed *)
|
Some
(
idx
,_
)
,
Index
(
_
,
NoOffset
)
,
SingleInit
init
->
begin
|
Index
(
_
,
NoOffset
)
,
SingleInit
init
->
begin
match
delayed
with
match
delayed
with
|
None
->
acc
,
Some
(
idx
,
Some
(
idx
,
off
,
init
))
|
(
i_prev
,
(
Some
(
_
,_,
init_delayed
)
as
delayed_info
))
|
Some
(
i_prev
,
(
Some
(
_
,_,
init_delayed
)
as
delayed_info
))
when
Wp_parameters
.
InitWithForall
.
get
()
when
Wp_parameters
.
InitWithForall
.
get
()
&&
Integer
.
equal
(
Integer
.
pred
i_prev
)
idx
&&
Integer
.
equal
(
Integer
.
pred
i_prev
)
idx
&&
ExpStructEq
.
equal
init_delayed
init
->
&&
ExpStructEq
.
equal
init_delayed
init
->
acc
,
Some
(
idx
,
delayed_info
)
acc
,
(
idx
,
delayed_info
)
|
_
->
(* flush the delayed init, and store the new one *)
|
_
->
(* flush the delayed init, and store the new one *)
let
acc
=
make_quant
acc
delayed
in
let
acc
=
make_quant
acc
delayed
in
acc
,
Some
(
idx
,
Some
(
idx
,
off
,
init
))
acc
,
(
idx
,
Some
(
idx
,
off
,
init
))
end
end
|
_
,
Index
(
_
,
_
)
,_
->
|
Index
(
_
,
_
)
,_
->
(* flush the delayed init, and adds the current one *)
(* flush the delayed init, and adds the current one *)
let
acc
=
make_quant
acc
delayed
in
let
acc
=
make_quant
acc
delayed
in
let
lv
=
Cil
.
addOffsetLval
off
lv
in
let
lv
=
Cil
.
addOffsetLval
off
lv
in
(
init_variable
~
sigma
lv
init
acc
)
,
idx
(
init_variable
~
sigma
lv
init
acc
)
,
(
idx
,
None
)
|
_
->
WpLog
.
fatal
"
Kernel
invariant broken
into
an in
itializer
"
|
_
->
WpLog
.
fatal
"
CIL
invariant broken
: not
an in
dex
"
)
)
(
acc
,
delayed
)
(
acc
,
delayed
)
(
List
.
rev
initl
)
(
List
.
rev
initl
)
...
...
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