For types with a parent of the compile unit make sure and emit

the DECL information.

rdar://10855921

llvm-svn: 152876
This commit is contained in:
Eric Christopher 2012-03-15 23:55:40 +00:00
parent b960db4427
commit 7734ca2891
5 changed files with 37 additions and 12 deletions

View File

@ -156,13 +156,12 @@ void CompileUnit::addSourceLine(DIE *Die, DISubprogram SP) {
// Verify subprogram. // Verify subprogram.
if (!SP.Verify()) if (!SP.Verify())
return; return;
// If the line number is 0, don't add it. // If the line number is 0, don't add it.
if (SP.getLineNumber() == 0) unsigned Line = SP.getLineNumber();
if (Line == 0)
return; return;
unsigned Line = SP.getLineNumber();
if (!SP.getContext().Verify())
return;
unsigned FileID = DD->GetOrCreateSourceID(SP.getFilename(), unsigned FileID = DD->GetOrCreateSourceID(SP.getFilename(),
SP.getDirectory()); SP.getDirectory());
assert(FileID && "Invalid file id"); assert(FileID && "Invalid file id");
@ -178,7 +177,7 @@ void CompileUnit::addSourceLine(DIE *Die, DIType Ty) {
return; return;
unsigned Line = Ty.getLineNumber(); unsigned Line = Ty.getLineNumber();
if (Line == 0 || !Ty.getContext().Verify()) if (Line == 0)
return; return;
unsigned FileID = DD->GetOrCreateSourceID(Ty.getFilename(), unsigned FileID = DD->GetOrCreateSourceID(Ty.getFilename(),
Ty.getDirectory()); Ty.getDirectory());

View File

@ -3,8 +3,8 @@
; test that the DW_AT_specification is a back edge in the file. ; test that the DW_AT_specification is a back edge in the file.
; CHECK: 0x00000038: DW_TAG_subprogram [5] * ; CHECK: 0x0000003a: DW_TAG_subprogram [5] *
; CHECK: 0x0000005e: DW_AT_specification [DW_FORM_ref4] (cu + 0x0038 => {0x00000038}) ; CHECK: 0x00000060: DW_AT_specification [DW_FORM_ref4] (cu + 0x003a => {0x0000003a})
@_ZZN3foo3barEvE1x = constant i32 0, align 4 @_ZZN3foo3barEvE1x = constant i32 0, align 4

View File

@ -7,7 +7,7 @@
; first check that we have a TAG_subprogram at a given offset and it has ; first check that we have a TAG_subprogram at a given offset and it has
; AT_inline. ; AT_inline.
; CHECK: 0x00000130: DW_TAG_subprogram [18] ; CHECK: 0x00000134: DW_TAG_subprogram [18]
; CHECK-NEXT: DW_AT_MIPS_linkage_name ; CHECK-NEXT: DW_AT_MIPS_linkage_name
; CHECK-NEXT: DW_AT_specification ; CHECK-NEXT: DW_AT_specification
; CHECK-NEXT: DW_AT_inline ; CHECK-NEXT: DW_AT_inline
@ -15,8 +15,8 @@
; and then that a TAG_subprogram refers to it with AT_abstract_origin. ; and then that a TAG_subprogram refers to it with AT_abstract_origin.
; CHECK: 0x00000180: DW_TAG_subprogram [20] ; CHECK: 0x00000184: DW_TAG_subprogram [20]
; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x0130 => {0x00000130}) ; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x0134 => {0x00000134})
define i32 @_ZN17nsAutoRefCnt7ReleaseEv() { define i32 @_ZN17nsAutoRefCnt7ReleaseEv() {
entry: entry:

View File

@ -3,8 +3,8 @@
; test that the DW_AT_specification is a back edge in the file. ; test that the DW_AT_specification is a back edge in the file.
; CHECK: 0x0000005a: DW_TAG_subprogram [5] ; CHECK: 0x0000005c: DW_TAG_subprogram [5]
; CHECK: 0x0000007a: DW_AT_specification [DW_FORM_ref4] (cu + 0x005a => {0x0000005a}) ; CHECK: 0x0000007c: DW_AT_specification [DW_FORM_ref4] (cu + 0x005c => {0x0000005c})
%struct.foo = type { i8 } %struct.foo = type { i8 }

View File

@ -0,0 +1,26 @@
; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
; RUN: llvm-dwarfdump %t | FileCheck %s
; Make sure that structures have a decl file and decl line attached.
; CHECK: DW_TAG_structure_type [3]
; CHECK: DW_AT_decl_file
; CHECK: DW_AT_decl_line
; CHECK: DW_TAG_member
%struct.foo = type { i32 }
@f = common global %struct.foo zeroinitializer, align 4
!llvm.dbg.cu = !{!0}
!0 = metadata !{i32 786449, i32 0, i32 12, metadata !"struct_bug.c", metadata !"/Users/echristo/tmp", metadata !"clang version 3.1 (trunk 152837) (llvm/trunk 152845)", i1 true, i1 false, metadata !"", i32 0, metadata !1, metadata !1, metadata !1, metadata !3} ; [ DW_TAG_compile_unit ]
!1 = metadata !{metadata !2}
!2 = metadata !{i32 0}
!3 = metadata !{metadata !4}
!4 = metadata !{metadata !5}
!5 = metadata !{i32 786484, i32 0, null, metadata !"f", metadata !"f", metadata !"", metadata !6, i32 5, metadata !7, i32 0, i32 1, %struct.foo* @f} ; [ DW_TAG_variable ]
!6 = metadata !{i32 786473, metadata !"struct_bug.c", metadata !"/Users/echristo/tmp", null} ; [ DW_TAG_file_type ]
!7 = metadata !{i32 786451, null, metadata !"foo", metadata !6, i32 1, i64 32, i64 32, i32 0, i32 0, null, metadata !8, i32 0, i32 0} ; [ DW_TAG_structure_type ]
!8 = metadata !{metadata !9}
!9 = metadata !{i32 786445, metadata !7, metadata !"a", metadata !6, i32 2, i64 32, i64 32, i64 0, i32 0, metadata !10} ; [ DW_TAG_member ]
!10 = metadata !{i32 786468, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]