@@ -550,7 +550,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
550550 ast_map:: node_item( ref item, _) => {
551551 match item. node {
552552 ast:: item_fn( ref fn_decl, _, _, ref generics, ref top_level_block) => {
553- ( item. ident , fn_decl, generics, Some ( top_level_block) , item. span )
553+ ( item. ident , fn_decl, generics, top_level_block, item. span )
554554 }
555555 _ => {
556556 cx. sess . span_bug ( item. span ,
@@ -569,7 +569,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
569569 } ,
570570 _,
571571 _) => {
572- ( ident, fn_decl, generics, Some ( top_level_block) , span)
572+ ( ident, fn_decl, generics, top_level_block, span)
573573 }
574574 ast_map:: node_expr( ref expr) => {
575575 match expr. node {
@@ -580,7 +580,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
580580 // This is not quite right. It should actually inherit the generics of the
581581 // enclosing function.
582582 & empty_generics,
583- Some ( top_level_block) ,
583+ top_level_block,
584584 expr. span )
585585 }
586586 _ => cx. sess . span_bug ( expr. span ,
@@ -599,7 +599,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
599599 } ) ,
600600 _,
601601 _) => {
602- ( ident, fn_decl, generics, Some ( top_level_block) , span)
602+ ( ident, fn_decl, generics, top_level_block, span)
603603 }
604604 ast_map:: node_foreign_item( @ast:: foreign_item { _ } , _, _, _) |
605605 ast_map:: node_variant( * ) |
@@ -624,11 +624,11 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
624624
625625 // get_template_parameters() will append a `<...>` clause to the function name if necessary.
626626 let mut function_name = token:: ident_to_str ( & ident) . to_owned ( ) ;
627- let template_parameters = if cx . sess . opts . extra_debuginfo {
628- get_template_parameters ( cx , generics , param_substs , file_metadata , & mut function_name )
629- } else {
630- ptr :: null ( )
631- } ;
627+ let template_parameters = get_template_parameters ( cx ,
628+ generics ,
629+ param_substs ,
630+ file_metadata ,
631+ & mut function_name ) ;
632632
633633 let namespace_node = debug_context ( cx) . local_namespace_map . find_copy ( & fn_ast_id) ;
634634 let ( linkage_name, containing_scope) = match namespace_node {
@@ -637,10 +637,9 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
637637 }
638638 None => {
639639 // This branch is only hit when there is a bug in the NamespaceVisitor.
640- cx. sess . span_warn ( span, "debuginfo: Could not find namespace node for function. \
641- This is a bug! Try running with RUST_LOG=rustc=1 \
642- to get further details and report the results \
643- to github.com/mozilla/rust/issues") ;
640+ cx. sess . span_warn ( span, fmt ! ( "debuginfo: Could not find namespace node for function
641+ with name %s. This is a bug! Please report this to
642+ github.com/mozilla/rust/issues" , function_name) ) ;
644643 ( function_name. clone ( ) , file_metadata)
645644 }
646645 } ;
@@ -680,16 +679,14 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
680679 let arg_pats = do fn_decl. inputs . map |arg_ref| { arg_ref. pat } ;
681680 populate_scope_map ( cx, arg_pats, top_level_block, fn_metadata, & mut fn_debug_context. scope_map ) ;
682681
683- match top_level_block {
684- Some ( top_level_block) => {
685- let mut namespace_visitor = NamespaceVisitor :: new_function_visitor ( cx,
686- function_name,
687- namespace_node,
688- file_metadata,
689- span) ;
690- visit:: walk_block ( & mut namespace_visitor, top_level_block, ( ) ) ;
691- }
692- _ => { /*nothing to do*/ }
682+ // Create namespaces for the interior of this function
683+ {
684+ let mut namespace_visitor = NamespaceVisitor :: new_function_visitor ( cx,
685+ function_name,
686+ namespace_node,
687+ file_metadata,
688+ span) ;
689+ visit:: walk_block ( & mut namespace_visitor, top_level_block, ( ) ) ;
693690 }
694691
695692 return FunctionDebugContext ( fn_debug_context) ;
@@ -757,7 +754,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
757754 let has_self_type = self_type. is_some ( ) ;
758755
759756 if !generics. is_type_parameterized ( ) && !has_self_type {
760- return ptr :: null ( ) ;
757+ return create_DIArray ( DIB ( cx ) , [ ] ) ;
761758 }
762759
763760 name_to_append_suffix_to. push_char ( '<' ) ;
@@ -768,33 +765,37 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
768765 // Handle self type
769766 if has_self_type {
770767 let actual_self_type = self_type. unwrap ( ) ;
771- let actual_self_type_metadata = type_metadata ( cx,
772- actual_self_type,
773- codemap:: dummy_sp ( ) ) ;
774-
775768 // Add self type name to <...> clause of function name
776769 let actual_self_type_name = ppaux:: ty_to_str ( cx. tcx , actual_self_type) ;
777770 name_to_append_suffix_to. push_str ( actual_self_type_name) ;
771+
778772 if generics. is_type_parameterized ( ) {
779773 name_to_append_suffix_to. push_str ( "," ) ;
780774 }
781775
782- let ident = special_idents:: type_self;
776+ // Only create type information if extra_debuginfo is enabled
777+ if cx. sess . opts . extra_debuginfo {
778+ let actual_self_type_metadata = type_metadata ( cx,
779+ actual_self_type,
780+ codemap:: dummy_sp ( ) ) ;
783781
784- let param_metadata = do token:: ident_to_str ( & ident) . to_c_str ( ) . with_ref |name| {
785- unsafe {
786- llvm:: LLVMDIBuilderCreateTemplateTypeParameter (
787- DIB ( cx) ,
788- file_metadata,
789- name,
790- actual_self_type_metadata,
791- ptr:: null ( ) ,
792- 0 ,
793- 0 )
794- }
795- } ;
782+ let ident = special_idents:: type_self;
783+
784+ let param_metadata = do token:: ident_to_str ( & ident) . to_c_str ( ) . with_ref |name| {
785+ unsafe {
786+ llvm:: LLVMDIBuilderCreateTemplateTypeParameter (
787+ DIB ( cx) ,
788+ file_metadata,
789+ name,
790+ actual_self_type_metadata,
791+ ptr:: null ( ) ,
792+ 0 ,
793+ 0 )
794+ }
795+ } ;
796796
797- template_params. push ( param_metadata) ;
797+ template_params. push ( param_metadata) ;
798+ }
798799 }
799800
800801 // Handle other generic parameters
@@ -807,8 +808,6 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
807808
808809 for ( index, & ast:: TyParam { ident : ident, _ } ) in generics. ty_params . iter ( ) . enumerate ( ) {
809810 let actual_type = actual_types[ index] ;
810- let actual_type_metadata = type_metadata ( cx, actual_type, codemap:: dummy_sp ( ) ) ;
811-
812811 // Add actual type name to <...> clause of function name
813812 let actual_type_name = ppaux:: ty_to_str ( cx. tcx , actual_type) ;
814813 name_to_append_suffix_to. push_str ( actual_type_name) ;
@@ -817,20 +816,23 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
817816 name_to_append_suffix_to. push_str ( "," ) ;
818817 }
819818
820- let param_metadata = do token:: ident_to_str ( & ident) . to_c_str ( ) . with_ref |name| {
821- unsafe {
822- llvm:: LLVMDIBuilderCreateTemplateTypeParameter (
823- DIB ( cx) ,
824- file_metadata,
825- name,
826- actual_type_metadata,
827- ptr:: null ( ) ,
828- 0 ,
829- 0 )
830- }
831- } ;
832-
833- template_params. push ( param_metadata) ;
819+ // Again, only create type information if extra_debuginfo is enabled
820+ if cx. sess . opts . extra_debuginfo {
821+ let actual_type_metadata = type_metadata ( cx, actual_type, codemap:: dummy_sp ( ) ) ;
822+ let param_metadata = do token:: ident_to_str ( & ident) . to_c_str ( ) . with_ref |name| {
823+ unsafe {
824+ llvm:: LLVMDIBuilderCreateTemplateTypeParameter (
825+ DIB ( cx) ,
826+ file_metadata,
827+ name,
828+ actual_type_metadata,
829+ ptr:: null ( ) ,
830+ 0 ,
831+ 0 )
832+ }
833+ } ;
834+ template_params. push ( param_metadata) ;
835+ }
834836 }
835837
836838 name_to_append_suffix_to. push_char ( '>' ) ;
@@ -839,14 +841,14 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
839841 }
840842
841843 fn get_scope_line ( cx : & CrateContext ,
842- top_level_block : Option < & ast:: Block > ,
844+ top_level_block : & ast:: Block ,
843845 default : uint )
844846 -> uint {
845- match top_level_block {
846- Some ( & ast:: Block { stmts : ref statements, _ } ) if statements. len ( ) > 0 => {
847+ match * top_level_block {
848+ ast:: Block { stmts : ref statements, _ } if statements. len ( ) > 0 => {
847849 span_start ( cx, statements[ 0 ] . span ) . line
848850 }
849- Some ( & ast:: Block { expr : Some ( @ref expr) , _ } ) => {
851+ ast:: Block { expr : Some ( @ref expr) , _ } => {
850852 span_start ( cx, expr. span ) . line
851853 }
852854 _ => default
@@ -2154,7 +2156,7 @@ fn get_namespace_and_span_for_item(cx: &mut CrateContext,
21542156// shadowing.
21552157fn populate_scope_map( cx : & mut CrateContext ,
21562158 arg_pats : & [ @ast:: Pat ] ,
2157- fn_entry_block : Option < & ast:: Block > ,
2159+ fn_entry_block : & ast:: Block ,
21582160 fn_metadata : DISubprogram ,
21592161 scope_map : & mut HashMap < ast:: NodeId , DIScope > ) {
21602162 let def_map = cx. tcx . def_map ;
@@ -2175,13 +2177,9 @@ fn populate_scope_map(cx: &mut CrateContext,
21752177 }
21762178 }
21772179
2178- for & fn_entry_block in fn_entry_block. iter ( ) {
2179- walk_block ( cx, fn_entry_block, & mut scope_stack, scope_map) ;
2180- }
2181-
2180+ walk_block ( cx, fn_entry_block, & mut scope_stack, scope_map) ;
21822181
21832182 // local helper functions for walking the AST.
2184-
21852183 fn with_new_scope ( cx : & mut CrateContext ,
21862184 scope_span : Span ,
21872185 scope_stack : & mut ~[ ScopeStackEntry ] ,
0 commit comments