Skip to content

Commit b7db392

Browse files
authored
Fix DW_TAG_template_alias refs in llvm-dwarfdump --verify (#89589)
A DW_TAG_template_alias referenced by a DW_AT_type incorrectly produces the error: error: DIE has DW_AT_type with incompatible tag DW_TAG_template_alias Fix and add test.
1 parent 093171b commit b7db392

File tree

2 files changed

+96
-1
lines changed

2 files changed

+96
-1
lines changed

llvm/include/llvm/BinaryFormat/Dwarf.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ HANDLE_DW_TAG(0x0040, shared_type, 3, DWARF, DW_KIND_TYPE)
203203
// New in DWARF v4:
204204
HANDLE_DW_TAG(0x0041, type_unit, 4, DWARF, DW_KIND_NONE)
205205
HANDLE_DW_TAG(0x0042, rvalue_reference_type, 4, DWARF, DW_KIND_TYPE)
206-
HANDLE_DW_TAG(0x0043, template_alias, 4, DWARF, DW_KIND_NONE)
206+
HANDLE_DW_TAG(0x0043, template_alias, 4, DWARF, DW_KIND_TYPE)
207207
// New in DWARF v5:
208208
HANDLE_DW_TAG(0x0044, coarray_type, 5, DWARF, DW_KIND_TYPE)
209209
HANDLE_DW_TAG(0x0045, generic_subrange, 5, DWARF, DW_KIND_NONE)
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# RUN: yaml2obj %s | llvm-dwarfdump --verify -
2+
3+
## Check --verify doesn't fail when a DW_AT_type references a
4+
## DW_TAG_template_alias.
5+
##
6+
## $ cat test.cpp
7+
## template <typename T>
8+
## using A = T;
9+
## A<bool> a;
10+
##
11+
## $ clang++ test.cpp -g -gtemplate-alias -gsimple-template-names
12+
13+
--- !ELF
14+
FileHeader:
15+
Class: ELFCLASS64
16+
Data: ELFDATA2LSB
17+
Type: ET_REL
18+
Machine: EM_X86_64
19+
DWARF:
20+
debug_str:
21+
- "clang version 19.0.0"
22+
- "a"
23+
- "A"
24+
- "T"
25+
- "bool"
26+
debug_abbrev:
27+
- Table:
28+
- Code: 0x0000000000000001
29+
Tag: DW_TAG_compile_unit
30+
Children: DW_CHILDREN_yes
31+
Attributes:
32+
- Attribute: DW_AT_name
33+
Form: DW_FORM_strp
34+
- Attribute: DW_AT_language
35+
Form: DW_FORM_data2
36+
- Code: 0x0000000000000002
37+
Tag: DW_TAG_base_type
38+
Children: DW_CHILDREN_no
39+
Attributes:
40+
- Attribute: DW_AT_name
41+
Form: DW_FORM_strp
42+
- Code: 0x0000000000000003
43+
Tag: DW_TAG_template_alias
44+
Children: DW_CHILDREN_yes
45+
Attributes:
46+
- Attribute: DW_AT_name
47+
Form: DW_FORM_strp
48+
- Attribute: DW_AT_type
49+
Form: DW_FORM_ref_addr
50+
- Code: 0x0000000000000004
51+
Tag: DW_TAG_template_type_parameter
52+
Children: DW_CHILDREN_no
53+
Attributes:
54+
- Attribute: DW_AT_name
55+
Form: DW_FORM_strp
56+
- Attribute: DW_AT_type
57+
Form: DW_FORM_ref_addr
58+
- Code: 0x0000000000000005
59+
Tag: DW_TAG_variable
60+
Children: DW_CHILDREN_no
61+
Attributes:
62+
- Attribute: DW_AT_name
63+
Form: DW_FORM_strp
64+
- Attribute: DW_AT_type
65+
Form: DW_FORM_ref_addr
66+
67+
debug_info:
68+
- Version: 4
69+
AbbrOffset: 0x0000000000000000
70+
AddrSize: 8
71+
Entries:
72+
- AbbrCode: 0x00000001
73+
Values:
74+
- Value: 0x0000000000000000
75+
- Value: 0x0000000000000021
76+
- AbbrCode: 0x00000002
77+
Values:
78+
- Value: 0x000000000000001b
79+
- AbbrCode: 0x00000003
80+
Values:
81+
- Value: 0x0000000000000017
82+
- Value: 0x0000000000000012
83+
- AbbrCode: 0x00000004
84+
Values:
85+
- Value: 0x0000000000000019
86+
- Value: 0x0000000000000012
87+
- AbbrCode: 0x00000000
88+
Values: []
89+
- AbbrCode: 0x00000005
90+
Values:
91+
- Value: 0x0000000000000015
92+
- Value: 0x0000000000000017
93+
- AbbrCode: 0x00000000
94+
Values: []
95+
...

0 commit comments

Comments
 (0)