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
3854f457
Commit
3854f457
authored
13 years ago
by
Julien Signoles
Browse files
Options
Downloads
Patches
Plain Diff
[e-acsl] prevent to add twice a generated variable to the locals of a function
parent
b8b2338f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/e-acsl/env.ml
+13
-7
13 additions, 7 deletions
src/plugins/e-acsl/env.ml
with
13 additions
and
7 deletions
src/plugins/e-acsl/env.ml
+
13
−
7
View file @
3854f457
...
@@ -30,7 +30,9 @@ let register_actions_queue q = queue := q
...
@@ -30,7 +30,9 @@ let register_actions_queue q = queue := q
type
t
=
type
t
=
{
var_cpt
:
int
;
(* counter used for generating variables in a function *)
{
var_cpt
:
int
;
(* counter used for generating variables in a function *)
fct_vars
:
varinfo
list
;
(* generated variables local to a function *)
fct_vars
:
Varinfo
.
Set
.
t
;
(* generated variables local to a function.
Use a set to prevent to add twice a variable
when merging. *)
block_vars
:
varinfo
list
;
(* generated variables local to a block.
block_vars
:
varinfo
list
;
(* generated variables local to a block.
Subset of field [vars] *)
Subset of field [vars] *)
beginning_of_block
:
stmt
list
;
(* list of stmts to be inserted before the
beginning_of_block
:
stmt
list
;
(* list of stmts to be inserted before the
...
@@ -40,7 +42,7 @@ type t =
...
@@ -40,7 +42,7 @@ type t =
let
empty
=
let
empty
=
{
var_cpt
=
0
;
{
var_cpt
=
0
;
fct_vars
=
[]
;
fct_vars
=
Varinfo
.
Set
.
empty
;
block_vars
=
[]
;
block_vars
=
[]
;
beginning_of_block
=
[]
;
beginning_of_block
=
[]
;
end_of_block
=
[]
}
end_of_block
=
[]
}
...
@@ -49,8 +51,9 @@ let no_overlap ~from env =
...
@@ -49,8 +51,9 @@ let no_overlap ~from env =
{
env
with
var_cpt
=
Extlib
.
max_cpt
from
.
var_cpt
env
.
var_cpt
}
{
env
with
var_cpt
=
Extlib
.
max_cpt
from
.
var_cpt
env
.
var_cpt
}
let
merge_function_vars
~
from
env
=
let
merge_function_vars
~
from
env
=
(* [TODO] the same variable may now appear twice in the list *)
{
env
with
{
env
with
var_cpt
=
from
.
var_cpt
;
fct_vars
=
env
.
fct_vars
@
from
.
fct_vars
}
var_cpt
=
from
.
var_cpt
;
fct_vars
=
Varinfo
.
Set
.
union
env
.
fct_vars
from
.
fct_vars
}
let
merge_block_vars
~
from
env
=
let
merge_block_vars
~
from
env
=
let
env
=
merge_function_vars
~
from
env
in
let
env
=
merge_function_vars
~
from
env
in
...
@@ -88,7 +91,7 @@ let new_var env ty mk_stmts =
...
@@ -88,7 +91,7 @@ let new_var env ty mk_stmts =
let
stmts
=
mk_stmts
v
e
in
let
stmts
=
mk_stmts
v
e
in
e
,
e
,
{
var_cpt
=
n
;
{
var_cpt
=
n
;
fct_vars
=
v
::
env
.
fct_vars
;
fct_vars
=
Varinfo
.
Set
.
add
v
env
.
fct_vars
;
block_vars
=
v
::
env
.
block_vars
;
block_vars
=
v
::
env
.
block_vars
;
beginning_of_block
=
beginning_of_block
=
List
.
fold_left
(
fun
l
s
->
s
::
l
)
env
.
beginning_of_block
stmts
;
List
.
fold_left
(
fun
l
s
->
s
::
l
)
env
.
beginning_of_block
stmts
;
...
@@ -98,7 +101,10 @@ let new_var env ty mk_stmts =
...
@@ -98,7 +101,10 @@ let new_var env ty mk_stmts =
let
new_var_and_mpz_init
env
mk_stmts
=
let
new_var_and_mpz_init
env
mk_stmts
=
new_var
env
Mpz
.
t
(
fun
v
e
->
Mpz
.
init
e
::
mk_stmts
v
e
)
new_var
env
Mpz
.
t
(
fun
v
e
->
Mpz
.
init
e
::
mk_stmts
v
e
)
let
generated_function_variables
env
=
List
.
rev
env
.
fct_vars
let
generated_function_variables
env
=
List
.
sort
(
fun
v1
v2
->
String
.
compare
v1
.
vname
v2
.
vname
)
(
Varinfo
.
Set
.
elements
env
.
fct_vars
)
let
generated_block_variables
env
=
List
.
rev
env
.
block_vars
let
generated_block_variables
env
=
List
.
rev
env
.
block_vars
...
@@ -123,7 +129,7 @@ let pretty fmt env =
...
@@ -123,7 +129,7 @@ let pretty fmt env =
Format
.
fprintf
fmt
"CPT = %d@
\n
"
env
.
var_cpt
;
Format
.
fprintf
fmt
"CPT = %d@
\n
"
env
.
var_cpt
;
Format
.
fprintf
fmt
"FCT_VARS = %t@
\n
"
Format
.
fprintf
fmt
"FCT_VARS = %t@
\n
"
(
fun
fmt
->
(
fun
fmt
->
Lis
t
.
iter
(
fun
v
->
Format
.
fprintf
fmt
"v%d "
v
.
vid
)
env
.
fct_vars
);
Varinfo
.
Se
t
.
iter
(
fun
v
->
Format
.
fprintf
fmt
"v%d "
v
.
vid
)
env
.
fct_vars
);
Format
.
fprintf
fmt
"BLOCK_VARS = %t@
\n
"
Format
.
fprintf
fmt
"BLOCK_VARS = %t@
\n
"
(
fun
fmt
->
(
fun
fmt
->
List
.
iter
(
fun
v
->
Format
.
fprintf
fmt
"v%d "
v
.
vid
)
env
.
block_vars
);
List
.
iter
(
fun
v
->
Format
.
fprintf
fmt
"v%d "
v
.
vid
)
env
.
block_vars
);
...
...
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