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
75945fff
Commit
75945fff
authored
4 years ago
by
Basile Desloges
Browse files
Options
Downloads
Patches
Plain Diff
[eacsl] Update code printer to support `__fc_vla_alloc()` and `__fc_vla_free()`
parent
b07b339c
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/e-acsl/src/main.ml
+34
-4
34 additions, 4 deletions
src/plugins/e-acsl/src/main.ml
with
34 additions
and
4 deletions
src/plugins/e-acsl/src/main.ml
+
34
−
4
View file @
75945fff
...
@@ -205,13 +205,43 @@ let change_printer =
...
@@ -205,13 +205,43 @@ let change_printer =
let
module
Printer_class
(
X
:
Printer
.
PrinterClass
)
=
struct
let
module
Printer_class
(
X
:
Printer
.
PrinterClass
)
=
struct
class
printer
=
object
class
printer
=
object
inherit
X
.
printer
as
super
inherit
X
.
printer
as
super
method
!
varinfo
fmt
vi
=
method
!
varinfo
fmt
vi
=
if
vi
.
Cil_types
.
vghost
||
vi
.
Cil_types
.
vstorage
<>
Cil_types
.
Extern
if
Functions
.
Libc
.
is_vla_alloc_name
vi
.
Cil_types
.
vname
then
then
(* Replace VLA allocation with calls to [__builtin_alloca] *)
super
#
varinfo
fmt
vi
Format
.
fprintf
fmt
"%s"
Functions
.
Libc
.
actual_alloca
else
else
if
(
not
vi
.
vghost
)
&&
vi
.
vstorage
==
Cil_types
.
Extern
then
(* Replace calls to Frama-C builtins with calls to their original
version from the libc *)
let
s
=
Str
.
replace_first
r
""
vi
.
Cil_types
.
vname
in
let
s
=
Str
.
replace_first
r
""
vi
.
Cil_types
.
vname
in
Format
.
fprintf
fmt
"%s"
s
Format
.
fprintf
fmt
"%s"
s
else
(* Otherwise use the original printer *)
super
#
varinfo
fmt
vi
method
!
instr
fmt
i
=
match
i
with
|
Call
(
_
,
fct
,
_
,
_
)
when
Functions
.
Libc
.
is_vla_free
fct
->
(* Nothing to print: VLA deallocation is done automatically when
leaving the scope *)
Format
.
fprintf
fmt
"/* "
;
super
#
instr
fmt
i
;
Format
.
fprintf
fmt
" */"
|
_
->
super
#
instr
fmt
i
method
!
global
fmt
g
=
let
is_vla_builtin
vi
=
Functions
.
Libc
.
is_vla_alloc_name
vi
.
Cil_types
.
vname
||
Functions
.
Libc
.
is_vla_free_name
vi
.
Cil_types
.
vname
in
match
g
with
|
GFunDecl
(
_
,
vi
,
_
)
when
is_vla_builtin
vi
->
(* Nothing to print: the VLA builtins don't have an original libc
version. *)
()
|
_
->
super
#
global
fmt
g
end
end
end
in
end
in
Printer
.
update_printer
(
module
Printer_class
:
Printer
.
PrinterExtension
)
Printer
.
update_printer
(
module
Printer_class
:
Printer
.
PrinterExtension
)
...
...
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