ZequanWu wrote:

For this specific case, we could fix it by making `DW_TAG_structure_type` 
equals to `DW_TAG_class_type` in the `UniqueDWARFASTTypeList::Find`. 

There's few things I noticed with this:
1. If `DW_TAG_structure_type` and `DW_TAG_class_type` are interchangeable, then 
this comparison on DIE tags also needs to be updated: 
https://github.com/llvm/llvm-project/blob/a871470a0d0c828718409c7a6dfb067a3231d013/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp#L40-L42,
 because the one parent DIE could be struct another one could be class and they 
need to be treated as matched.
2. I wonder why this is not a problem before this change. Before, when 
`ParseStructureLikeDIE` sees a struct declaration, it searches for definition 
DIE from type index, which just checks for the fully qualified name of the 
types. So, it will find the DIE `DW_TAG_class_type` as a definition DIE and 
create one type from the definition DIE. If `ParseStructureLikeDIE` sees the 
class definition first. the lldb will be created and `UniqueDWARFASTTypeMap` 
will have a cache of the type. Later when `ParseStructureLikeDIE` parses the 
struct declaration, it will still failed to find the cache type in the 
`UniqueDWARFASTTypeMap` but the call to `FindDefinitionTypeForDWARFDeclContext` 
will find the definition DIE using fully qualified name which avoid creating 
the type twice.

So, basically this PR relies `UniqueDWARFASTTypeMap` to correctly find the 
mapping from declaration DIEs to definition DIE and start definition on the 
clang type (might created from declaration), while it had a backup call to 
`FindDefinitionTypeForDWARFDeclContext` to find definition DIE with just fully 
qualified name before this PR. 

In case of we failed to find existing clang type (created from declaration) in 
`UniqueDWARFASTTypeMap`, I think it's good to start definition in 
`CompleteRecordType` if the clang type hasn't started its definition. Sent 
https://github.com/llvm/llvm-project/pull/93839 to fix it.

https://github.com/llvm/llvm-project/pull/92328
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to