Michael137 wrote:
Sorry for the delay. Thanks for adding the test. That was really helpful
This is the DWARF of the test yaml:
```
test.o: file format elf64-x86-64
.debug_info contents:
0x00000000: Compile Unit: length = 0x0000009e, format = DWARF32, version =
0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x000000a2)
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("GNU C++14 9.4.0 -mtune=generic -march=x86-64
-g -O0 -fasynchronous-unwind-tables -fstack-protector-strong
-fstack-clash-protection -fcf-protection")
DW_AT_language (DW_LANG_C_plus_plus)
DW_AT_name ("maic.cc")
DW_AT_comp_dir ("/root/os-llvm/llvm-project")
DW_AT_low_pc (0x0000000000001129)
DW_AT_high_pc (0x0000000000001138)
DW_AT_stmt_list (0x00000000)
0x0000002d: DW_TAG_structure_type
DW_AT_name ("Type")
DW_AT_byte_size (0x01)
DW_AT_decl_file ("/root/os-llvm/llvm-project/maic.cc")
DW_AT_decl_line (1)
DW_AT_decl_column (8)
0x00000036: DW_TAG_structure_type
DW_AT_name ("_Optional_payload<Type, true, false, false>")
DW_AT_byte_size (0x01)
DW_AT_decl_file ("/root/os-llvm/llvm-project/maic.cc")
DW_AT_decl_line (5)
DW_AT_decl_column (32)
DW_AT_sibling (0x0000004d)
0x00000043: DW_TAG_template_type_parameter
DW_AT_name ("_Tp")
DW_AT_type (0x0000002d "Type")
0x0000004c: NULL
0x0000004d: DW_TAG_structure_type
DW_AT_name ("_Optional_payload<Type, false, false, true>")
DW_AT_byte_size (0x01)
DW_AT_decl_file ("/root/os-llvm/llvm-project/maic.cc")
DW_AT_decl_line (8)
DW_AT_decl_column (8)
DW_AT_sibling (0x0000006a)
0x0000005a: DW_TAG_inheritance
DW_AT_type (0x00000036 "_Optional_payload<Type, true,
false, false>")
DW_AT_data_member_location (0x00)
0x00000060: DW_TAG_template_type_parameter
DW_AT_name ("_Tp")
DW_AT_type (0x0000002d "Type")
0x00000069: NULL
```
So basically we have a `_Optional_payload` specialization that inherits from a
different `_Optional_payload` specialization. LLDB creates two different
`ClassTemplateSpecializationDecl`s for these, but because the two
specializations are missing the `DW_TAG_template_value_parameter`s, in the
final AST, Clang thinks they are the same. So the ASTImporter ends up making a
decl that inherits from itself, as you mention in the PR description.
Presumably this happens because they structurally match, and the ASTImporter
re-uses one of the previously imported specialization decl. Your patch makes
our AST construction less brittle (and this is also what Clang and the
ASTImporter do). So generally this LGTM
https://github.com/llvm/llvm-project/pull/154123
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits