@@ -136,6 +136,13 @@ fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool {
136
136
}
137
137
}
138
138
139
+ fn span_is_empty ( opt_span : & Option < span > ) -> bool {
140
+ match * opt_span {
141
+ None => true ,
142
+ Some ( span) => * span. lo == 0 && * span. hi == 0
143
+ }
144
+ }
145
+
139
146
struct StatRecorder < ' self > {
140
147
ccx : @mut CrateContext ,
141
148
name : & ' self str ,
@@ -1623,6 +1630,13 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
1623
1630
}
1624
1631
} ;
1625
1632
let uses_outptr = type_of:: return_uses_outptr ( ccx. tcx , substd_output_type) ;
1633
+
1634
+ let debug_context = if id != -1 && ccx. sess . opts . debuginfo && !span_is_empty ( & sp) {
1635
+ Some ( debuginfo:: create_function_debug_context ( ccx, id, param_substs, llfndecl) )
1636
+ } else {
1637
+ None
1638
+ } ;
1639
+
1626
1640
let fcx = @mut FunctionContext {
1627
1641
llfn : llfndecl,
1628
1642
llenv : unsafe {
@@ -1643,7 +1657,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
1643
1657
span : sp,
1644
1658
path : path,
1645
1659
ccx : ccx,
1646
- debug_context : None ,
1660
+ debug_context : debug_context ,
1647
1661
} ;
1648
1662
fcx. llenv = unsafe {
1649
1663
llvm:: LLVMGetParam ( llfndecl, fcx. env_arg_pos ( ) as c_uint )
@@ -1880,10 +1894,6 @@ pub fn trans_closure(ccx: @mut CrateContext,
1880
1894
set_fixed_stack_segment ( fcx. llfn ) ;
1881
1895
}
1882
1896
1883
- if ccx. sess . opts . debuginfo && fcx_has_nonzero_span ( fcx) {
1884
- debuginfo:: create_function_metadata ( fcx) ;
1885
- }
1886
-
1887
1897
// Create the first basic block in the function and keep a handle on it to
1888
1898
// pass to finish_fn later.
1889
1899
let bcx_top = fcx. entry_bcx . unwrap ( ) ;
0 commit comments