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
let
delayed
=
match
len
with
(* number of required elements *)
|
Some
{
enode
=
(
Const
CInt64
(
size
,_,_
))}
->
Some
(
size
,
None
)
|
_
->
None
(
size
,
None
)
|
_
->
(* CIL invariant broken. *)
WpLog
.
fatal
"CIL invariant broken: unknown initialized array size"
in
let
make_quant
acc
=
function
(* adds delayed initializations from info about
(* adds delayed initializations from info about
the last consecutive indices having
the same value, but that have not yet initialized. *)
|
None
->
acc
(* nothing was delayed *)
|
Some
(
_
,
None
)
->
acc
(* nothing was delayed *)
|
Some
(
il
,
Some
(
i0
,_,
exp
))
when
Integer
.
lt
il
i0
->
|
(
_
,
None
)
->
acc
(* nothing was delayed *)
|
(
il
,
Some
(
i0
,_,
exp
))
when
Integer
.
lt
il
i0
->
(* Added pred: \forall i \in [il .. i0] ; t[i]==exp *)
let
i2
=
Integer
.
succ
i0
in
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]
Added pred: t[i]==exp*)
let
lv
=
Cil
.
addOffsetLval
off
lv
in
...
...
@@ -518,12 +518,11 @@ struct
in
let
add_missing_indices
acc
i0
=
function
(* adds eventual default value for missing indices. *)
|
Some
(
i1
,
_
)
->
|
(
i1
,
_
)
->
if
Integer
.
ge
i0
i1
then
(* no hole *)
acc
else
(* defaults values
Added pred: \forall i \in [i0 .. i1[ ; t[i]==default *)
init_range
~
sigma
lv
ty
i0
i1
None
::
acc
|
_
->
(* last bound is unknown. *)
acc
in
let
acc
,
delayed
=
List
.
fold_left
...
...
@@ -532,35 +531,36 @@ struct
let
idx
,
acc
=
match
off
with
|
Index
({
enode
=
Const
CInt64
(
idx
,_,_
)}
,
_
)
->
(
match
delayed
with
|
Some
(
iprev
,
_
)
when
Integer
.
lt
iprev
idx
->
(* otherwice, an algo with a 2sd pass is
required for introducing default values *)
WpLog
.
fatal
"Unordered initializer"
;
|
(
iprev
,
_
)
when
Integer
.
lt
iprev
idx
->
(* CIL invariant broken.
without that invariant, an algo with a 2sd pass
is required for introducing default values *)
WpLog
.
fatal
"CIL invariant broken: unordered initializer"
;
|
_
->
()
)
;
Some
(
idx
,
None
)
,
idx
,
(* adds default values for missing indices *)
add_missing_indices
acc
(
Integer
.
succ
idx
)
delayed
|
_
->
None
,
acc
|
_
->
(* CIL invariant broken. *)
WpLog
.
fatal
"CIL invariant broken: unknown initialized index"
in
match
idx
,
off
,
init
with
(* only simple init can be delayed *)
|
Some
(
idx
,_
)
,
Index
(
_
,
NoOffset
)
,
SingleInit
init
->
begin
match
off
,
init
with
(* only simple init can be delayed *)
|
Index
(
_
,
NoOffset
)
,
SingleInit
init
->
begin
match
delayed
with
|
None
->
acc
,
Some
(
idx
,
Some
(
idx
,
off
,
init
))
|
Some
(
i_prev
,
(
Some
(
_
,_,
init_delayed
)
as
delayed_info
))
|
(
i_prev
,
(
Some
(
_
,_,
init_delayed
)
as
delayed_info
))
when
Wp_parameters
.
InitWithForall
.
get
()
&&
Integer
.
equal
(
Integer
.
pred
i_prev
)
idx
&&
ExpStructEq
.
equal
init_delayed
init
->
acc
,
Some
(
idx
,
delayed_info
)
acc
,
(
idx
,
delayed_info
)
|
_
->
(* flush the delayed init, and store the new one *)
let
acc
=
make_quant
acc
delayed
in
acc
,
Some
(
idx
,
Some
(
idx
,
off
,
init
))
acc
,
(
idx
,
Some
(
idx
,
off
,
init
))
end
|
_
,
Index
(
_
,
_
)
,_
->
|
Index
(
_
,
_
)
,_
->
(* flush the delayed init, and adds the current one *)
let
acc
=
make_quant
acc
delayed
in
let
lv
=
Cil
.
addOffsetLval
off
lv
in
(
init_variable
~
sigma
lv
init
acc
)
,
idx
|
_
->
WpLog
.
fatal
"
Kernel
invariant broken
into
an in
itializer
"
(
init_variable
~
sigma
lv
init
acc
)
,
(
idx
,
None
)
|
_
->
WpLog
.
fatal
"
CIL
invariant broken
: not
an in
dex
"
)
(
acc
,
delayed
)
(
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