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
pub
frama-c
Commits
404c8c60
Commit
404c8c60
authored
Dec 17, 2019
by
Julien Signoles
Committed by
Michele Alberti
Dec 17, 2019
Browse files
[e-acsl:archi] restore correct behavior of ghost parameters
parent
24e83690
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/e-acsl/src/code_generator/injector.ml
View file @
404c8c60
...
...
@@ -568,6 +568,11 @@ let inject_in_fundec main fundec =
(* convert ghost variables *)
vi
.
vghost
<-
false
;
List
.
iter
(
fun
vi
->
vi
.
vghost
<-
false
)
fundec
.
slocals
;
let
unghost_formal
vi
=
vi
.
vghost
<-
false
;
vi
.
vattr
<-
Cil
.
dropAttribute
Cil
.
frama_c_ghost_formal
vi
.
vattr
in
List
.
iter
unghost_formal
fundec
.
sformals
;
(* update environments *)
Builtins
.
update
vi
.
vname
vi
;
(* track function addresses but the main function that is tracked internally
...
...
@@ -575,9 +580,9 @@ let inject_in_fundec main fundec =
if
not
(
Kernel_function
.
is_main
kf
)
then
Global_observer
.
add
vi
;
(* exit point computations *)
if
Functions
.
instrument
kf
then
Exit_points
.
generate
fundec
;
(* recursive visit *)
Options
.
feedback
~
dkey
~
level
:
2
"entering in function %a."
Kernel_function
.
pretty
kf
;
(* recursive visit *)
let
env
=
inject_in_block
Env
.
empty
kf
fundec
.
sbody
in
Exit_points
.
clear
()
;
add_generated_variables_in_function
env
fundec
;
...
...
@@ -592,6 +597,18 @@ let inject_in_fundec main fundec =
(* The whole AST *)
(* ************************************************************************** *)
let
unghost_vi
vi
=
(* do not convert extern ghost variables, because they can't be linked,
see bts #1392 *)
if
vi
.
vstorage
<>
Extern
then
vi
.
vghost
<-
false
;
match
Cil
.
unrollType
vi
.
vtype
with
|
TFun
(
res
,
Some
l
,
va
,
attr
)
->
(* unghostify function's parameters *)
let
retype
(
n
,
t
,
a
)
=
n
,
t
,
Cil
.
dropAttribute
Cil
.
frama_c_ghost_formal
a
in
vi
.
vtype
<-
TFun
(
res
,
Some
(
List
.
map
retype
l
)
,
va
,
attr
)
|
_
->
()
let
inject_in_global
(
env
,
main
)
=
function
(* library functions and built-ins *)
|
GVarDecl
(
vi
,
_
)
|
GVar
(
vi
,
_
,
_
)
...
...
@@ -610,21 +627,19 @@ let inject_in_global (env, main) = function
(* variable declarations *)
|
GVarDecl
(
vi
,
_
)
|
GFunDecl
(
_
,
vi
,
_
)
->
(* do not convert extern ghost variables, because they can't be linked,
see bts #1392 *)
if
vi
.
vstorage
<>
Extern
then
vi
.
vghost
<-
false
;
unghost_vi
vi
;
Global_observer
.
add
vi
;
env
,
main
(* variable definition *)
|
GVar
(
vi
,
{
init
=
None
}
,
_
)
->
Global_observer
.
add
vi
;
vi
.
v
ghost
<-
false
;
un
ghost
_vi
vi
;
env
,
main
|
GVar
(
vi
,
{
init
=
Some
init
}
,
_
)
->
Global_observer
.
add
vi
;
vi
.
v
ghost
<-
false
;
un
ghost
_vi
vi
;
let
_init
,
env
=
inject_in_init
env
None
vi
NoOffset
init
in
(* ignore the new initializer that handles literal strings since they are
not substituted in global initializers (see
...
...
@@ -632,7 +647,8 @@ let inject_in_global (env, main) = function
env
,
main
(* function definition *)
|
GFun
(
fundec
,
_
)
->
|
GFun
({
svar
=
vi
}
as
fundec
,
_
)
->
unghost_vi
vi
;
inject_in_fundec
main
fundec
(* other globals: nothing to do *)
...
...
src/plugins/e-acsl/tests/memory/oracle_ci/gen_ghost_parameters.c
View file @
404c8c60
/* Generated by Frama-C */
#include "stdio.h"
#include "stdlib.h"
void
function
(
int
a
,
int
b
)
/*@ ghost (
int c, int d)
*/
void
function
(
int
a
,
int
b
,
int
c
,
int
d
)
{
return
;
}
...
...
@@ -14,7 +14,7 @@ int main(void)
int
x
=
1
;
int
y
=
2
;
int
z
=
3
;
function
(
w
,
x
)
/*@ ghost (
y,z)
*/
;
function
(
w
,
x
,
y
,
z
);
__retres
=
0
;
return
__retres
;
}
...
...
Write
Preview
Supports
Markdown
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