@@ -20,7 +20,7 @@ use self::namespace::mangled_name_of_item;
20
20
use self :: type_names:: compute_debuginfo_type_name;
21
21
use self :: metadata:: { type_metadata, diverging_type_metadata} ;
22
22
use self :: metadata:: { file_metadata, scope_metadata, TypeMap , compile_unit_metadata} ;
23
- use self :: source_loc:: InternalDebugLocation ;
23
+ use self :: source_loc:: InternalDebugLocation :: { self , UnknownLocation } ;
24
24
25
25
use llvm;
26
26
use llvm:: { ModuleRef , ContextRef , ValueRef } ;
@@ -32,7 +32,7 @@ use rustc::ty::subst::Substs;
32
32
use rustc:: hir;
33
33
34
34
use abi:: Abi ;
35
- use common:: { NodeIdAndSpan , CrateContext , FunctionContext , Block } ;
35
+ use common:: { NodeIdAndSpan , CrateContext , FunctionContext , Block , BlockAndBuilder } ;
36
36
use monomorphize:: Instance ;
37
37
use rustc:: ty:: { self , Ty } ;
38
38
use session:: config:: { self , FullDebugInfo , LimitedDebugInfo , NoDebugInfo } ;
@@ -55,8 +55,7 @@ mod metadata;
55
55
mod create_scope_map;
56
56
mod source_loc;
57
57
58
- pub use self :: source_loc:: set_source_location;
59
- pub use self :: source_loc:: clear_source_location;
58
+ pub use self :: create_scope_map:: create_mir_scopes;
60
59
pub use self :: source_loc:: start_emitting_source_locations;
61
60
pub use self :: source_loc:: get_cleanup_debug_loc_for_ast_node;
62
61
pub use self :: source_loc:: with_source_location_override;
@@ -218,7 +217,7 @@ pub fn empty_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>)
218
217
}
219
218
220
219
// Clear the debug location so we don't assign them in the function prelude.
221
- source_loc:: set_debug_location ( cx, InternalDebugLocation :: UnknownLocation ) ;
220
+ source_loc:: set_debug_location ( cx, None , UnknownLocation ) ;
222
221
FunctionDebugContext :: FunctionWithoutDebugInfo
223
222
}
224
223
@@ -239,7 +238,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
239
238
240
239
// Clear the debug location so we don't assign them in the function prelude.
241
240
// Do this here already, in case we do an early exit from this function.
242
- source_loc:: set_debug_location ( cx, InternalDebugLocation :: UnknownLocation ) ;
241
+ source_loc:: set_debug_location ( cx, None , UnknownLocation ) ;
243
242
244
243
// This can be the case for functions inlined from another crate
245
244
let ( containing_scope, span) = get_namespace_and_span_for_item ( cx, instance. def ) ;
@@ -425,13 +424,13 @@ pub fn fill_scope_map_for_function<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
425
424
}
426
425
}
427
426
428
- fn declare_local < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
429
- variable_name : ast:: Name ,
430
- variable_type : Ty < ' tcx > ,
431
- scope_metadata : DIScope ,
432
- variable_access : VariableAccess ,
433
- variable_kind : VariableKind ,
434
- span : Span ) {
427
+ pub fn declare_local < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
428
+ variable_name : ast:: Name ,
429
+ variable_type : Ty < ' tcx > ,
430
+ scope_metadata : DIScope ,
431
+ variable_access : VariableAccess ,
432
+ variable_kind : VariableKind ,
433
+ span : Span ) {
435
434
let cx: & CrateContext = bcx. ccx ( ) ;
436
435
437
436
let filename = span_start ( cx, span) . file . name . clone ( ) ;
@@ -465,9 +464,8 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
465
464
address_operations. len ( ) as c_uint ,
466
465
argument_index)
467
466
} ;
468
- source_loc:: set_debug_location ( cx, InternalDebugLocation :: new ( scope_metadata,
469
- loc. line ,
470
- loc. col . to_usize ( ) ) ) ;
467
+ source_loc:: set_debug_location ( cx, None ,
468
+ InternalDebugLocation :: new ( scope_metadata, loc. line , loc. col . to_usize ( ) ) ) ;
471
469
unsafe {
472
470
let debug_loc = llvm:: LLVMGetCurrentDebugLocation ( cx. raw_builder ( ) ) ;
473
471
let instr = llvm:: LLVMDIBuilderInsertDeclareAtEnd (
@@ -491,7 +489,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
491
489
. get_ref( span)
492
490
. source_locations_enabled
493
491
. get( ) ) ;
494
- source_loc:: set_debug_location ( cx, InternalDebugLocation :: UnknownLocation ) ;
492
+ source_loc:: set_debug_location ( cx, None , UnknownLocation ) ;
495
493
}
496
494
_ => { /* nothing to do */ }
497
495
}
@@ -500,19 +498,17 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
500
498
#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
501
499
pub enum DebugLoc {
502
500
At ( ast:: NodeId , Span ) ,
501
+ ScopeAt ( DIScope , Span ) ,
503
502
None
504
503
}
505
504
506
505
impl DebugLoc {
507
- pub fn apply ( & self , fcx : & FunctionContext ) {
508
- match * self {
509
- DebugLoc :: At ( node_id, span) => {
510
- source_loc:: set_source_location ( fcx, node_id, span) ;
511
- }
512
- DebugLoc :: None => {
513
- source_loc:: clear_source_location ( fcx) ;
514
- }
515
- }
506
+ pub fn apply ( self , fcx : & FunctionContext ) {
507
+ source_loc:: set_source_location ( fcx, None , self ) ;
508
+ }
509
+
510
+ pub fn apply_to_bcx ( self , bcx : & BlockAndBuilder ) {
511
+ source_loc:: set_source_location ( bcx. fcx ( ) , Some ( bcx) , self ) ;
516
512
}
517
513
}
518
514
0 commit comments