Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pub
frama-c
Commits
9fef4530
Commit
9fef4530
authored
Oct 09, 2020
by
Basile Desloges
Browse files
[variadic] Print original functions in output
parent
41b68f17
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/variadic/register.ml
View file @
9fef4530
...
...
@@ -20,8 +20,43 @@
(* *)
(**************************************************************************)
open
Cil_types
let
category
=
File
.
register_code_transformation_category
"variadic"
(* Variadic will create prototype and specifications for some variadic
functions. Since only prototypes are created, the resulting source code isn't
compilable. This printer will print the original functions, with the replaced
prototypes in comments beside the instruction. *)
let
change_printer
=
let
first
=
ref
true
in
fun
()
->
if
!
first
then
begin
first
:=
false
;
let
module
Printer_class
(
X
:
Printer
.
PrinterClass
)
=
struct
class
printer
=
object
inherit
X
.
printer
as
super
method
!
instr
fmt
i
=
match
i
with
(* If the instruction calls a function that have been replaced,
then build an instruction with the old function. *)
|
Call
(
res
,
({
enode
=
Lval
(
Var
vi
,
o
)
}
as
fct
)
,
args
,
loc
)
when
Replacements
.
mem
vi
->
let
old_vi
=
Replacements
.
find
vi
in
let
old_vi
=
{
vi
with
vname
=
old_vi
.
vname
}
in
let
old_instr
=
Call
(
res
,
{
fct
with
enode
=
Lval
(
Var
old_vi
,
o
)
}
,
args
,
loc
)
in
Format
.
fprintf
fmt
"%a /* %s */"
super
#
instr
old_instr
vi
.
vname
(* Otherwise keep the instruction. *)
|
_
->
super
#
instr
fmt
i
end
end
in
Printer
.
update_printer
(
module
Printer_class
:
Printer
.
PrinterExtension
)
end
let
()
=
Cmdline
.
run_after_extended_stage
begin
fun
()
->
...
...
@@ -32,8 +67,10 @@ let () =
Cmdline
.
run_after_configuring_stage
begin
fun
()
->
let
translate
file
=
if
Options
.
Enabled
.
get
()
then
if
Options
.
Enabled
.
get
()
then
begin
change_printer
()
;
Translate
.
translate_variadics
file
end
in
File
.
add_code_transformation_before_cleanup
category
translate
end
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