@@ -23,7 +23,7 @@ import front::attr;
23
23
import middle:: { ty, gc, resolve, debuginfo} ;
24
24
import middle:: freevars:: * ;
25
25
import back:: { link, abi, upcall} ;
26
- import syntax:: { ast, ast_util} ;
26
+ import syntax:: { ast, ast_util, codemap } ;
27
27
import syntax:: visit;
28
28
import syntax:: codemap:: span;
29
29
import syntax:: print:: pprust:: { expr_to_str, stmt_to_str} ;
@@ -4038,10 +4038,22 @@ fn trans_stmt(cx: @block_ctxt, s: ast::stmt) -> @block_ctxt {
4038
4038
_ { bcx_ccx( cx) . sess . unimpl ( "stmt variant" ) ; }
4039
4039
}
4040
4040
4041
- //debuginfo::reset_source_pos(cx);
4042
4041
ret bcx;
4043
4042
}
4044
4043
4044
+ fn source_pos_from_block_parent ( parent : block_parent )
4045
+ -> ( bool , [ codemap:: loc ] ) {
4046
+ alt parent {
4047
+ parent_none. { ( false , [ ] ) }
4048
+ parent_some ( bcx) { ( bcx. source_pos . usable ,
4049
+ alt vec:: last ( bcx. source_pos . pos ) {
4050
+ option:: some ( p) { [ p] }
4051
+ option:: none. { [ ] }
4052
+ } )
4053
+ }
4054
+ }
4055
+ }
4056
+
4045
4057
// You probably don't want to use this one. See the
4046
4058
// next three functions instead.
4047
4059
fn new_block_ctxt ( cx : @fn_ctxt , parent : block_parent , kind : block_kind ,
@@ -4053,6 +4065,7 @@ fn new_block_ctxt(cx: @fn_ctxt, parent: block_parent, kind: block_kind,
4053
4065
}
4054
4066
let llbb: BasicBlockRef =
4055
4067
str:: as_buf ( s, { |buf| llvm:: LLVMAppendBasicBlock ( cx. llfn , buf) } ) ;
4068
+ let ( usable, pos) = source_pos_from_block_parent ( parent) ;
4056
4069
let bcx = @{ llbb: llbb,
4057
4070
mutable terminated: false ,
4058
4071
mutable unreachable: false ,
@@ -4063,8 +4076,7 @@ fn new_block_ctxt(cx: @fn_ctxt, parent: block_parent, kind: block_kind,
4063
4076
mutable lpad: option:: none,
4064
4077
sp: cx. sp ,
4065
4078
fcx: cx,
4066
- source_pos : { mutable usable: false ,
4067
- mutable pos: [ ] } } ;
4079
+ source_pos : { mutable usable: usable, mutable pos: pos} } ;
4068
4080
alt parent {
4069
4081
parent_some( cx) {
4070
4082
if cx. unreachable { Unreachable ( bcx) ; }
@@ -4099,6 +4111,7 @@ fn new_sub_block_ctxt(bcx: @block_ctxt, n: str) -> @block_ctxt {
4099
4111
}
4100
4112
4101
4113
fn new_raw_block_ctxt ( fcx : @fn_ctxt , llbb : BasicBlockRef ) -> @block_ctxt {
4114
+ let ( usable, pos) = source_pos_from_block_parent ( parent_none) ;
4102
4115
ret @{ llbb : llbb,
4103
4116
mutable terminated : false ,
4104
4117
mutable unreachable : false ,
@@ -4109,8 +4122,7 @@ fn new_raw_block_ctxt(fcx: @fn_ctxt, llbb: BasicBlockRef) -> @block_ctxt {
4109
4122
mutable lpad: option:: none,
4110
4123
sp : fcx. sp ,
4111
4124
fcx : fcx,
4112
- source_pos : { mutable usable: false ,
4113
- mutable pos: [ ] } } ;
4125
+ source_pos : { mutable usable: usable, mutable pos: pos} } ;
4114
4126
}
4115
4127
4116
4128
@@ -4168,6 +4180,7 @@ fn block_locals(b: ast::blk, it: block(@ast::local)) {
4168
4180
}
4169
4181
4170
4182
fn llstaticallocas_block_ctxt ( fcx : @fn_ctxt ) -> @block_ctxt {
4183
+ let ( usable, pos) = source_pos_from_block_parent ( parent_none) ;
4171
4184
ret @{ llbb : fcx. llstaticallocas ,
4172
4185
mutable terminated : false ,
4173
4186
mutable unreachable : false ,
@@ -4178,11 +4191,11 @@ fn llstaticallocas_block_ctxt(fcx: @fn_ctxt) -> @block_ctxt {
4178
4191
mutable lpad: option:: none,
4179
4192
sp : fcx. sp ,
4180
4193
fcx : fcx,
4181
- source_pos : { mutable usable: false ,
4182
- mutable pos: [ ] } } ;
4194
+ source_pos : { mutable usable: usable, mutable pos: pos} } ;
4183
4195
}
4184
4196
4185
4197
fn llderivedtydescs_block_ctxt ( fcx : @fn_ctxt ) -> @block_ctxt {
4198
+ let ( usable, pos) = source_pos_from_block_parent ( parent_none) ;
4186
4199
ret @{ llbb : fcx. llderivedtydescs ,
4187
4200
mutable terminated : false ,
4188
4201
mutable unreachable : false ,
@@ -4193,8 +4206,7 @@ fn llderivedtydescs_block_ctxt(fcx: @fn_ctxt) -> @block_ctxt {
4193
4206
mutable lpad: option:: none,
4194
4207
sp : fcx. sp ,
4195
4208
fcx : fcx,
4196
- source_pos : { mutable usable: false ,
4197
- mutable pos: [ ] } } ;
4209
+ source_pos : { mutable usable: usable, mutable pos: pos} } ;
4198
4210
}
4199
4211
4200
4212
@@ -4271,14 +4283,12 @@ fn trans_block_dps(bcx: @block_ctxt, b: ast::blk, dest: dest)
4271
4283
for s: @ast:: stmt in b. node . stmts {
4272
4284
let _s = debuginfo:: update_source_pos ( bcx, b. span ) ;
4273
4285
bcx = trans_stmt ( bcx, * s) ;
4274
- //debuginfo::reset_source_pos(bcx);
4275
4286
}
4276
4287
alt b. node . expr {
4277
4288
some ( e) {
4278
4289
let bt = ty:: type_is_bot ( bcx_tcx ( bcx) , ty:: expr_ty ( bcx_tcx ( bcx) , e) ) ;
4279
4290
let _s = debuginfo:: update_source_pos ( bcx, e. span ) ;
4280
4291
bcx = trans_expr ( bcx, e, bt ? ignore : dest) ;
4281
- //debuginfo::reset_source_pos(bcx);
4282
4292
}
4283
4293
_ { assert dest == ignore || bcx. unreachable ; }
4284
4294
}
0 commit comments