This fixes some cases of missing debuginfo caused by an interaction between:f0d66559ea, which drops the identifier from a DICompositeType in the module containing its vtable. anda61f5e3796, which causes ThinLTO to import composite types as declarations when they have an identifier. If a virtual class's DICompositeType has no identifier due to the first change, and contains a nested anonymous type which does have an identifier, then the second change can cause ThinLTO to output the classes's DICompositeType as a type definition that links to a non-defining declaration for the nested type. Since the nested anonyous type does not have a name, debuggers are unable to find the definition for the declaration. Repro case: ``` cat > a.h <<EOF class A { public: A(); virtual ~A(); private: union { int val; }; }; EOF cat > a.cc <<EOF #include "a.h" A::A() { asm(""); } A::~A() {} EOF cat > main.cc <<EOF #include "a.h" int main(int argc, char **argv) { A a; return 0; } EOF clang++ -O2 -g -flto=thin -mllvm -force-import-all main.cc a.cc gdb ./a.out -batch -ex 'pt /rmt A' ``` The gdb command outputs: ``` type = class A { private: union { <incomplete type> }; } ``` and dwarfdump -i a.out shows a DW_TAG_class_type for A with an incomplete union type (note that there is also a duplicate entry with the full union type that comes after). ``` < 1><0x0000001e> DW_TAG_class_type DW_AT_containing_type <0x0000001e> DW_AT_calling_convention DW_CC_pass_by_reference DW_AT_name (indexed string: 0x00000007)A DW_AT_byte_size 0x00000010 DW_AT_decl_file 0x00000001 /path/to/./a.h DW_AT_decl_line 0x00000001 ... < 2><0x0000002f> DW_TAG_member DW_AT_type <0x00000037> DW_AT_decl_file 0x00000001 /path/to/./a.h DW_AT_decl_line 0x00000007 DW_AT_data_member_location 8 < 2><0x00000037> DW_TAG_union_type DW_AT_export_symbols yes(1) DW_AT_calling_convention DW_CC_pass_by_value DW_AT_declaration yes(1) ``` This change works around this by making ThinLTO always import full definitions for anonymous types.
89 KiB
89 KiB