Skip to content

Commit 24c3dab

Browse files
committed
DebugInfo: Emit class template parameters first, before members
This reads more like what you'd expect the DWARF to look like (from the lexical order of C++ - template parameters come before members, etc), and also happens to make it easier to tickle (& thus test) a bug related to type units and Split DWARF I'm about to fix.
1 parent 8abd69a commit 24c3dab

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,11 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
891891
}
892892
}
893893

894+
// Add template parameters to a class, structure or union types.
895+
if (Tag == dwarf::DW_TAG_class_type ||
896+
Tag == dwarf::DW_TAG_structure_type || Tag == dwarf::DW_TAG_union_type)
897+
addTemplateParams(Buffer, CTy->getTemplateParams());
898+
894899
// Add elements to structure type.
895900
DINodeArray Elements = CTy->getElements();
896901
for (const auto *Element : Elements) {
@@ -960,12 +965,6 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
960965
if (CTy->isObjcClassComplete())
961966
addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
962967

963-
// Add template parameters to a class, structure or union types.
964-
// FIXME: The support isn't in the metadata for this yet.
965-
if (Tag == dwarf::DW_TAG_class_type ||
966-
Tag == dwarf::DW_TAG_structure_type || Tag == dwarf::DW_TAG_union_type)
967-
addTemplateParams(Buffer, CTy->getTemplateParams());
968-
969968
// Add the type's non-standard calling convention.
970969
uint8_t CC = 0;
971970
if (CTy->isTypePassByValue())

llvm/test/DebugInfo/Generic/template-recursive-void.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
; CHECK: DW_TAG_template_type_parameter [{{.*}}]
1515
; CHECK-NEXT: DW_AT_name{{.*}}"T"
1616
; CHECK-NOT: DW_AT_type
17-
; CHECK: NULL
17+
; CHECK: {{DW_TAG|NULL}}
1818

1919
source_filename = "test/DebugInfo/Generic/template-recursive-void.ll"
2020

0 commit comments

Comments
 (0)