File tree 3 files changed +24
-0
lines changed
3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1892,6 +1892,13 @@ pub fn codegen(context: &mut BindgenContext) -> Vec<P<ast::Item>> {
1892
1892
1893
1893
let whitelisted_items: ItemSet = context. whitelisted_items ( ) . collect ( ) ;
1894
1894
1895
+ if context. options ( ) . emit_ir {
1896
+ for & id in whitelisted_items. iter ( ) {
1897
+ let item = context. resolve_item ( id) ;
1898
+ println ! ( "ir: {:?} = {:#?}" , id, item) ;
1899
+ }
1900
+ }
1901
+
1895
1902
for & id in whitelisted_items. iter ( ) {
1896
1903
let item = context. resolve_item ( id) ;
1897
1904
Original file line number Diff line number Diff line change @@ -225,6 +225,12 @@ impl Builder {
225
225
self
226
226
}
227
227
228
+ /// Emit IR.
229
+ pub fn emit_ir ( mut self ) -> Builder {
230
+ self . options . emit_ir = true ;
231
+ self
232
+ }
233
+
228
234
/// Enable C++ namespaces.
229
235
pub fn enable_cxx_namespaces ( mut self ) -> Builder {
230
236
self . options . enable_cxx_namespaces = true ;
@@ -314,6 +320,9 @@ pub struct BindgenOptions {
314
320
/// True if we should dump the Clang AST for debugging purposes.
315
321
pub emit_ast : bool ,
316
322
323
+ /// True if we should dump our internal IR for debugging purposes.
324
+ pub emit_ir : bool ,
325
+
317
326
/// True if we should ignore functions and only generate bindings for
318
327
/// structures, types, and methods.
319
328
pub ignore_functions : bool ,
@@ -380,6 +389,7 @@ impl Default for BindgenOptions {
380
389
builtins : false ,
381
390
links : vec ! [ ] ,
382
391
emit_ast : false ,
392
+ emit_ir : false ,
383
393
ignore_functions : false ,
384
394
ignore_methods : false ,
385
395
derive_debug : true ,
Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ pub fn builder_from_flags<I>(args: I)
52
52
Arg :: with_name ( "emit-clang-ast" )
53
53
. long ( "emit-clang-ast" )
54
54
. help ( "Output the Clang AST for debugging purposes." ) ,
55
+ Arg :: with_name ( "emit-ir" )
56
+ . long ( "emit-ir" )
57
+ . help ( "Output our internal IR for debugging purposes." ) ,
55
58
Arg :: with_name ( "enable-cxx-namespaces" )
56
59
. long ( "enable-cxx-namespaces" )
57
60
. help ( "Enable support for C++ namespaces." ) ,
@@ -183,6 +186,10 @@ pub fn builder_from_flags<I>(args: I)
183
186
builder = builder. emit_clang_ast ( ) ;
184
187
}
185
188
189
+ if matches. is_present ( "emit-ir" ) {
190
+ builder = builder. emit_ir ( ) ;
191
+ }
192
+
186
193
if matches. is_present ( "enable-cxx-namespaces" ) {
187
194
builder = builder. enable_cxx_namespaces ( ) ;
188
195
}
You can’t perform that action at this time.
0 commit comments