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 @@ -55,6 +55,9 @@ pub fn builder_from_flags<I>(args: I)
55
55
Arg :: with_name ( "emit-clang-ast" )
56
56
. long ( "emit-clang-ast" )
57
57
. help ( "Output the Clang AST for debugging purposes." ) ,
58
+ Arg :: with_name ( "emit-ir" )
59
+ . long ( "emit-ir" )
60
+ . help ( "Output our internal IR for debugging purposes." ) ,
58
61
Arg :: with_name ( "enable-cxx-namespaces" )
59
62
. long ( "enable-cxx-namespaces" )
60
63
. help ( "Enable support for C++ namespaces." ) ,
@@ -186,6 +189,10 @@ pub fn builder_from_flags<I>(args: I)
186
189
builder = builder. emit_clang_ast ( ) ;
187
190
}
188
191
192
+ if matches. is_present ( "emit-ir" ) {
193
+ builder = builder. emit_ir ( ) ;
194
+ }
195
+
189
196
if matches. is_present ( "enable-cxx-namespaces" ) {
190
197
builder = builder. enable_cxx_namespaces ( ) ;
191
198
}
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 @@ -228,6 +228,12 @@ impl Builder {
228
228
self
229
229
}
230
230
231
+ /// Emit IR.
232
+ pub fn emit_ir ( mut self ) -> Builder {
233
+ self . options . emit_ir = true ;
234
+ self
235
+ }
236
+
231
237
/// Enable C++ namespaces.
232
238
pub fn enable_cxx_namespaces ( mut self ) -> Builder {
233
239
self . options . enable_cxx_namespaces = true ;
@@ -317,6 +323,9 @@ pub struct BindgenOptions {
317
323
/// True if we should dump the Clang AST for debugging purposes.
318
324
pub emit_ast : bool ,
319
325
326
+ /// True if we should dump our internal IR for debugging purposes.
327
+ pub emit_ir : bool ,
328
+
320
329
/// True if we should ignore functions and only generate bindings for
321
330
/// structures, types, and methods.
322
331
pub ignore_functions : bool ,
@@ -383,6 +392,7 @@ impl Default for BindgenOptions {
383
392
builtins : false ,
384
393
links : vec ! [ ] ,
385
394
emit_ast : false ,
395
+ emit_ir : false ,
386
396
ignore_functions : false ,
387
397
ignore_methods : false ,
388
398
derive_debug : true ,
You can’t perform that action at this time.
0 commit comments