@@ -20,7 +20,7 @@ use self::namespace::mangled_name_of_item;
2020use self :: type_names:: compute_debuginfo_type_name;
2121use self :: metadata:: { type_metadata, diverging_type_metadata} ;
2222use self :: metadata:: { file_metadata, scope_metadata, TypeMap , compile_unit_metadata} ;
23- use self :: source_loc:: InternalDebugLocation ;
23+ use self :: source_loc:: InternalDebugLocation :: { self , UnknownLocation } ;
2424
2525use llvm;
2626use llvm:: { ModuleRef , ContextRef , ValueRef } ;
@@ -32,7 +32,7 @@ use rustc::ty::subst::Substs;
3232use rustc:: hir;
3333
3434use abi:: Abi ;
35- use common:: { NodeIdAndSpan , CrateContext , FunctionContext , Block } ;
35+ use common:: { NodeIdAndSpan , CrateContext , FunctionContext , Block , BlockAndBuilder } ;
3636use monomorphize:: Instance ;
3737use rustc:: ty:: { self , Ty } ;
3838use session:: config:: { self , FullDebugInfo , LimitedDebugInfo , NoDebugInfo } ;
@@ -55,8 +55,7 @@ mod metadata;
5555mod create_scope_map;
5656mod source_loc;
5757
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;
6059pub use self :: source_loc:: start_emitting_source_locations;
6160pub use self :: source_loc:: get_cleanup_debug_loc_for_ast_node;
6261pub use self :: source_loc:: with_source_location_override;
@@ -218,7 +217,7 @@ pub fn empty_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>)
218217 }
219218
220219 // 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 ) ;
222221 FunctionDebugContext :: FunctionWithoutDebugInfo
223222}
224223
@@ -239,7 +238,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
239238
240239 // Clear the debug location so we don't assign them in the function prelude.
241240 // 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 ) ;
243242
244243 // This can be the case for functions inlined from another crate
245244 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>,
425424 }
426425}
427426
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 ) {
435434 let cx: & CrateContext = bcx. ccx ( ) ;
436435
437436 let filename = span_start ( cx, span) . file . name . clone ( ) ;
@@ -465,9 +464,8 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
465464 address_operations. len ( ) as c_uint ,
466465 argument_index)
467466 } ;
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 ( ) ) ) ;
471469 unsafe {
472470 let debug_loc = llvm:: LLVMGetCurrentDebugLocation ( cx. raw_builder ( ) ) ;
473471 let instr = llvm:: LLVMDIBuilderInsertDeclareAtEnd (
@@ -491,7 +489,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
491489 . get_ref( span)
492490 . source_locations_enabled
493491 . get( ) ) ;
494- source_loc:: set_debug_location ( cx, InternalDebugLocation :: UnknownLocation ) ;
492+ source_loc:: set_debug_location ( cx, None , UnknownLocation ) ;
495493 }
496494 _ => { /* nothing to do */ }
497495 }
@@ -500,19 +498,17 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
500498#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
501499pub enum DebugLoc {
502500 At ( ast:: NodeId , Span ) ,
501+ ScopeAt ( DIScope , Span ) ,
503502 None
504503}
505504
506505impl 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 ) ;
516512 }
517513}
518514
0 commit comments