Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Charles Southerland
frama-c
Commits
f8f9cd0f
Commit
f8f9cd0f
authored
Nov 06, 2020
by
Allan Blanchard
Browse files
[parser] Narrow froms in case of inclusion
parent
a0ada244
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/kernel_internals/parsing/logic_parser.mly
View file @
f8f9cd0f
...
...
@@ -116,16 +116,16 @@
let
f
ds
d
=
if
List
.
exists
(
is_same_lexpr
d
)
ds
then
ds
else
d
::
ds
in
l
,
From
(
List
.(
rev
(
fold_left
f
[]
ds
)))
let
concat_froms
a1
a2
=
let
compare_pair
(
b
1
,_
)
(
b
2
,_
)
=
is_same_lexpr
b1
b2
in
let
concat_froms
cura
newa
=
let
compare_pair
(
cur
b
,_
)
(
new
b
,_
)
=
is_same_lexpr
curb
newb
in
(* NB: the following has an horrible complexity, but the order of
clauses in the input is preserved. *)
let
concat_one
acc
(
l
,
f
2
)
=
let
(
_
,
f
2
)
as
p
=
filter_from
l
f
2
in
let
concat_one
acc
(
l
,
new
f
)
=
let
(
_
,
new
f
)
as
p
=
filter_from
l
new
f
in
try
let
(
_
,
f
1
)
=
List
.
find
(
compare_pair
p
)
acc
let
(
_
,
cur
f
)
=
List
.
find
(
compare_pair
p
)
acc
in
match
(
f1
,
f2
)
with
match
(
curf
,
newf
)
with
|
_
,
FromAny
->
(* the new fundeps does not give more information than the one
which is already present. Just ignore it.
...
...
@@ -138,12 +138,15 @@
that we get the exact same clause if we try to
link the original contract with its pretty-printed version. *)
Extlib
.
replace
compare_pair
p
acc
|
From
_
,
From
_
->
(* we keep the two functional dependencies,
as they have to be proved separately. *)
acc
@
[
p
]
|
From
curl
,
From
newl
->
let
incl
l
lin
=
List
.(
for_all
(
fun
e
->
exists
(
is_same_lexpr
e
)
lin
)
l
)
in
if
incl
curl
newl
then
acc
else
if
incl
newl
curl
then
Extlib
.
replace
compare_pair
p
acc
else
acc
@
[
p
]
with
Not_found
->
acc
@
[
p
]
in
List
.
fold_left
concat_one
a1
a2
in
List
.
fold_left
concat_one
cura
newa
let
concat_allocation
fa1
fa2
=
match
fa1
,
fa2
with
...
...
tests/rte/oracle/assign4.res.oracle
View file @
f8f9cd0f
...
...
@@ -6,9 +6,7 @@
int choose1(int min, int max);
/*@ assigns \result;
assigns \result \from min, max;
assigns \result \from min, max;
*/
assigns \result \from min, max; */
int choose2(int min, int max);
int main(void)
...
...
tests/rte/oracle/assign5.res.oracle
View file @
f8f9cd0f
...
...
@@ -2,13 +2,11 @@
[rte] annotating function main
/* Generated by Frama-C */
/*@ assigns *p;
assigns *p \from x;
assigns *p \from \nothing; */
int f(int *p, int x);
/*@ assigns *p;
assigns *p \from \nothing;
assigns *p \from x; */
assigns *p \from \nothing; */
int g(int *p, int x);
int main(void)
...
...
tests/syntax/multiple_froms.i
View file @
f8f9cd0f
int
a
,
b
,
c
,
d
,
e
;
// Reminder: assigns are visited in reverse
/*@ assigns a;
assigns a \from a, a, b, c, c;
assigns a \from a, a, b, c, c;
// more precise so replace the next one
assigns a \from c, b, d, e, a;
assigns a;
assigns b \from a, e, b, d, c;
assigns c \from c, c, c, c, c;
assigns b \from a, e, b, d, c; // is ignored because the next one is more precise
assigns b \from a, e;
assigns c \from c, c, c, c, c; // both are kept (no inclusion)
assigns c \from d;
*/
void
function
(
void
)
{
...
...
tests/syntax/oracle/multiple_froms.res.oracle
View file @
f8f9cd0f
...
...
@@ -7,9 +7,9 @@ int d;
int e;
/*@ assigns a, b, c;
assigns a \from a, b, c;
assigns a \from c, b, d, e, a;
assigns b \from a, e, b, d, c;
assigns b \from a, e;
assigns c \from c;
assigns c \from d;
*/
void function(void)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment