Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1985,6 +1985,7 @@ return dwarf::PubIndexEntryDescriptor(dwarf::GIEK_FUNCTION, Linkage); case dwarf::DW_TAG_constant: case dwarf::DW_TAG_variable: + case dwarf::DW_TAG_member: return dwarf::PubIndexEntryDescriptor(dwarf::GIEK_VARIABLE, Linkage); case dwarf::DW_TAG_enumerator: return dwarf::PubIndexEntryDescriptor(dwarf::GIEK_VARIABLE, Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1674,23 +1674,12 @@ DD->addArangeLabel(SymbolCU(this, Sym)); addOpAddress(*Loc, Sym); } - // A static member's declaration is already flagged as such. - if (!SDMDecl.Verify() && !GV.isDefinition()) + + if (!GV.isDefinition()) addFlag(*VariableDIE, dwarf::DW_AT_declaration); - // Do not create specification DIE if context is either compile unit - // or a subprogram. - if (GVContext && GV.isDefinition() && !GVContext.isCompileUnit() && - !GVContext.isFile() && !DD->isSubprogramContext(GVContext)) { - // Create specification DIE. - VariableSpecDIE = &createAndAddDIE(dwarf::DW_TAG_variable, UnitDie); - addDIEEntry(*VariableSpecDIE, dwarf::DW_AT_specification, *VariableDIE); - addBlock(*VariableSpecDIE, dwarf::DW_AT_location, Loc); - // A static member's declaration is already flagged as such. - if (!SDMDecl.Verify()) - addFlag(*VariableDIE, dwarf::DW_AT_declaration); - } else { - addBlock(*VariableDIE, dwarf::DW_AT_location, Loc); - } + + addBlock(*VariableDIE, dwarf::DW_AT_location, Loc); + // Add the linkage name. StringRef LinkageName = GV.getLinkageName(); if (!LinkageName.empty()) @@ -2010,7 +1999,6 @@ addType(StaticMemberDIE, Ty); addSourceLine(StaticMemberDIE, DT); addFlag(StaticMemberDIE, dwarf::DW_AT_external); - addFlag(StaticMemberDIE, dwarf::DW_AT_declaration); // FIXME: We could omit private if the parent is a class_type, and // public if the parent is something else. Index: test/DebugInfo/X86/debug-info-static-member.ll =================================================================== --- test/DebugInfo/X86/debug-info-static-member.ll +++ test/DebugInfo/X86/debug-info-static-member.ll @@ -100,17 +100,22 @@ ; PRESENT: 0x[[DECL_A:[0-9a-f]+]]: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "a" ; PRESENT: DW_AT_external -; PRESENT: DW_AT_declaration +; PRESENT-NOT: DW_AT_declaration ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private) +; PRESENT-NEXT: DW_AT_location +; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE" ; PRESENT: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "const_a" ; PRESENT: DW_AT_external -; PRESENT: DW_AT_declaration +; PRESENT-NOT: DW_AT_declaration ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private) ; PRESENT: DW_AT_const_value {{.*}} (1) ; PRESENT: 0x[[DECL_B:[0-9a-f]+]]: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "b" ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected) +; PRESENT-NOT: DW_AT_declaration +; PRESENT-NEXT: DW_AT_location +; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE" ; PRESENT: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "const_b" ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected) @@ -118,6 +123,9 @@ ; PRESENT: 0x[[DECL_C:[0-9a-f]+]]: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "c" ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) +; PRESENT-NOT: DW_AT_declaration +; PRESENT-NEXT: DW_AT_location +; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE" ; PRESENT: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "const_c" ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) @@ -129,19 +137,6 @@ ; PRESENT: DW_AT_data_member_location ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) ; PRESENT: NULL -; Definitions point back to their declarations, and have a location. -; PRESENT: DW_TAG_variable -; PRESENT-NEXT: DW_AT_specification {{.*}} {0x[[DECL_A]]} -; PRESENT-NEXT: DW_AT_location -; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE" -; PRESENT: DW_TAG_variable -; PRESENT-NEXT: DW_AT_specification {{.*}} {0x[[DECL_B]]} -; PRESENT-NEXT: DW_AT_location -; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE" -; PRESENT: DW_TAG_variable -; PRESENT-NEXT: DW_AT_specification {{.*}} {0x[[DECL_C]]} -; PRESENT-NEXT: DW_AT_location -; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE" ; For Darwin gdb: ; DARWINP: .debug_info contents: @@ -150,17 +145,19 @@ ; DARWINP: 0x[[DECL_A:[0-9a-f]+]]: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "a" ; DARWINP: DW_AT_external -; DARWINP: DW_AT_declaration ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private) +; DARWINP-NEXT: DW_AT_location +; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE" ; DARWINP: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "const_a" ; DARWINP: DW_AT_external -; DARWINP: DW_AT_declaration ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private) ; DARWINP: DW_AT_const_value {{.*}} (1) ; DARWINP: 0x[[DECL_B:[0-9a-f]+]]: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "b" ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected) +; DARWINP-NEXT: DW_AT_location +; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE" ; DARWINP: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "const_b" ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected) @@ -168,6 +165,8 @@ ; DARWINP: 0x[[DECL_C:[0-9a-f]+]]: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "c" ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) +; DARWINP-NEXT: DW_AT_location +; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE" ; DARWINP: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "const_c" ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) @@ -179,19 +178,6 @@ ; DARWINP: DW_AT_data_member_location ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) ; DARWINP: NULL -; Definitions point back to their declarations, and have a location. -; DARWINP: DW_TAG_variable -; DARWINP-NEXT: DW_AT_specification {{.*}} {0x[[DECL_A]]} -; DARWINP-NEXT: DW_AT_location -; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE" -; DARWINP: DW_TAG_variable -; DARWINP-NEXT: DW_AT_specification {{.*}} {0x[[DECL_B]]} -; DARWINP-NEXT: DW_AT_location -; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE" -; DARWINP: DW_TAG_variable -; DARWINP-NEXT: DW_AT_specification {{.*}} {0x[[DECL_C]]} -; DARWINP-NEXT: DW_AT_location -; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE" ; ABSENT verifies that static member declarations do not have either ; DW_AT_location or DW_AT_data_member_location; also, variables do not @@ -201,19 +187,16 @@ ; ABSENT: DW_TAG_member ; ABSENT: DW_AT_name {{.*}} "a" ; ABSENT-NOT: DW_AT_const_value -; ABSENT-NOT: location ; ABSENT: DW_AT_name {{.*}} "const_a" ; ABSENT-NOT: DW_AT_linkage_name ; ABSENT-NOT: location ; ABSENT: DW_AT_name {{.*}} "b" ; ABSENT-NOT: DW_AT_const_value -; ABSENT-NOT: location ; ABSENT: DW_AT_name {{.*}} "const_b" ; ABSENT-NOT: DW_AT_linkage_name ; ABSENT-NOT: location ; ABSENT: DW_AT_name {{.*}} "c" ; ABSENT-NOT: DW_AT_const_value -; ABSENT-NOT: location ; ABSENT: DW_AT_name {{.*}} "const_c" ; ABSENT-NOT: DW_AT_linkage_name ; ABSENT-NOT: location @@ -230,19 +213,16 @@ ; DARWINA: DW_TAG_member ; DARWINA: DW_AT_name {{.*}} "a" ; DARWINA-NOT: DW_AT_const_value -; DARWINA-NOT: location ; DARWINA: DW_AT_name {{.*}} "const_a" ; DARWINA-NOT: DW_AT_linkage_name ; DARWINA-NOT: location ; DARWINA: DW_AT_name {{.*}} "b" ; DARWINA-NOT: DW_AT_const_value -; DARWINA-NOT: location ; DARWINA: DW_AT_name {{.*}} "const_b" ; DARWINA-NOT: DW_AT_linkage_name ; DARWINA-NOT: location ; DARWINA: DW_AT_name {{.*}} "c" ; DARWINA-NOT: DW_AT_const_value -; DARWINA-NOT: location ; DARWINA: DW_AT_name {{.*}} "const_c" ; DARWINA-NOT: DW_AT_linkage_name ; DARWINA-NOT: location Index: test/DebugInfo/X86/gnu-public-names.ll =================================================================== --- test/DebugInfo/X86/gnu-public-names.ll +++ test/DebugInfo/X86/gnu-public-names.ll @@ -52,7 +52,7 @@ ; CHECK: [[C:0x[0-9a-f]+]]: DW_TAG_structure_type ; CHECK-NEXT: DW_AT_name {{.*}} "C" -; CHECK: [[STATIC_MEM_DECL:0x[0-9a-f]+]]: DW_TAG_member +; CHECK: [[STATIC_MEM_VAR:0x[0-9a-f]+]]: DW_TAG_member ; CHECK-NEXT: DW_AT_name {{.*}} "static_member_variable" ; CHECK: [[MEM_FUNC_DECL:0x[0-9a-f]+]]: DW_TAG_subprogram @@ -66,19 +66,16 @@ ; CHECK: [[INT:0x[0-9a-f]+]]: DW_TAG_base_type ; CHECK-NEXT: DW_AT_name {{.*}} "int" -; CHECK: [[STATIC_MEM_VAR:0x[0-9a-f]+]]: DW_TAG_variable -; CHECK-NEXT: DW_AT_specification {{.*}} {[[STATIC_MEM_DECL]]} - ; CHECK: [[GLOB_VAR:0x[0-9a-f]+]]: DW_TAG_variable ; CHECK-NEXT: DW_AT_name {{.*}} "global_variable" ; CHECK: [[NS:0x[0-9a-f]+]]: DW_TAG_namespace ; CHECK-NEXT: DW_AT_name {{.*}} "ns" -; CHECK: [[GLOB_NS_VAR_DECL:0x[0-9a-f]+]]: DW_TAG_variable +; CHECK: [[GLOB_NS_VAR:0x[0-9a-f]+]]: DW_TAG_variable ; CHECK-NEXT: DW_AT_name {{.*}} "global_namespace_variable" -; CHECK: [[D_VAR_DECL:0x[0-9a-f]+]]: DW_TAG_variable +; CHECK: [[D_VAR:0x[0-9a-f]+]]: DW_TAG_variable ; CHECK-NEXT: DW_AT_name {{.*}} "d" ; CHECK: [[D:0x[0-9a-f]+]]: DW_TAG_structure_type @@ -90,12 +87,6 @@ ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "global_namespace_function" -; CHECK: [[GLOB_NS_VAR:0x[0-9a-f]+]]: DW_TAG_variable -; CHECK-NEXT: DW_AT_specification {{.*}} {[[GLOB_NS_VAR_DECL]]} - -; CHECK: [[D_VAR:0x[0-9a-f]+]]: DW_TAG_variable -; CHECK-NEXT: DW_AT_specification {{.*}} {[[D_VAR_DECL]]} - ; CHECK: DW_TAG_subprogram ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "f3" @@ -116,7 +107,7 @@ ; CHECK: [[OUTER_ANON:.*]]: DW_TAG_namespace ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK-NOT: DW_AT_name -; CHECK: [[OUTER_ANON_C_DECL:.*]]: DW_TAG_variable +; CHECK: [[OUTER_ANON_C:.*]]: DW_TAG_variable ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "c" ; CHECK-NOT: {{DW_TAG|NULL}} @@ -129,9 +120,6 @@ ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: NULL ; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[OUTER_ANON_C:.*]]: DW_TAG_variable -; CHECK-NOT: DW_TAG -; CHECK-NEXT: DW_AT_specification {{.*}} {[[OUTER_ANON_C_DECL]]} ; CHECK: [[ANON:.*]]: DW_TAG_namespace ; CHECK-NOT: DW_AT_name @@ -139,24 +127,18 @@ ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "inner" ; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[ANON_INNER_B_DECL:.*]]: DW_TAG_variable +; CHECK: [[ANON_INNER_B:.*]]: DW_TAG_variable ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "b" ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: NULL ; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[ANON_I_DECL:.*]]: DW_TAG_variable +; CHECK: [[ANON_I:.*]]: DW_TAG_variable ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "i" ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: NULL ; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[ANON_INNER_B:.*]]: DW_TAG_variable -; CHECK-NOT: DW_TAG -; CHECK-NEXT: DW_AT_specification {{.*}} {[[ANON_INNER_B_DECL]]} -; CHECK: [[ANON_I:.*]]: DW_TAG_variable -; CHECK-NOT: DW_TAG -; CHECK-NEXT: DW_AT_specification {{.*}} {[[ANON_I_DECL]]} ; CHECK: [[MEM_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram ; CHECK-NOT: DW_TAG