File tree Expand file tree Collapse file tree 5 files changed +15
-2
lines changed Expand file tree Collapse file tree 5 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -519,7 +519,7 @@ impl TypedAstContext {
519
519
}
520
520
}
521
521
522
- pub fn prune_unused_decls ( & mut self ) {
522
+ pub fn prune_unused_decls ( & mut self , preserve_unused_functions : bool ) {
523
523
// Starting from a set of root declarations, walk each one to find declarations it
524
524
// depends on. Then walk each of those, recursively.
525
525
@@ -545,6 +545,13 @@ impl TypedAstContext {
545
545
to_walk. push ( decl_id) ;
546
546
used. insert ( decl_id) ;
547
547
}
548
+ CDeclKind :: Function {
549
+ body : Some ( _) ,
550
+ ..
551
+ } if preserve_unused_functions => {
552
+ to_walk. push ( decl_id) ;
553
+ used. insert ( decl_id) ;
554
+ }
548
555
CDeclKind :: Variable {
549
556
is_defn : true ,
550
557
is_externally_visible : true ,
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ pub struct TranspilerConfig {
109
109
pub translate_const_macros : bool ,
110
110
pub translate_fn_macros : bool ,
111
111
pub disable_refactoring : bool ,
112
+ pub preserve_unused_functions : bool ,
112
113
pub log_level : log:: LevelFilter ,
113
114
114
115
// Options that control build files
Original file line number Diff line number Diff line change @@ -530,7 +530,7 @@ pub fn translate(
530
530
531
531
// Headers often pull in declarations that are unused;
532
532
// we simplify the translator output by omitting those.
533
- t. ast_context . prune_unused_decls ( ) ;
533
+ t. ast_context . prune_unused_decls ( tcfg . preserve_unused_functions ) ;
534
534
535
535
enum Name < ' a > {
536
536
VarName ( & ' a str ) ,
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ fn main() {
89
89
translate_const_macros : matches. is_present ( "translate-const-macros" ) ,
90
90
translate_fn_macros : matches. is_present ( "translate-fn-macros" ) ,
91
91
disable_refactoring : matches. is_present ( "disable-refactoring" ) ,
92
+ preserve_unused_functions : matches. is_present ( "preserve-unused-functions" ) ,
92
93
93
94
use_c_loop_info : !matches. is_present ( "ignore-c-loop-info" ) ,
94
95
use_c_multiple_info : !matches. is_present ( "ignore-c-multiple-info" ) ,
Original file line number Diff line number Diff line change @@ -172,6 +172,10 @@ args:
172
172
long : disable-refactoring
173
173
help : Disable running refactoring tool after translation
174
174
takes_value : false
175
+ - preserve-unused-functions :
176
+ long : preserve-unused-functions
177
+ help : Include static and inline functions in translation
178
+ takes_value : false
175
179
- log-level :
176
180
long : log-level
177
181
help : Logging level
You can’t perform that action at this time.
0 commit comments