<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58143>58143</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang++ doesn't always add complete information for a class
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
billionai
</td>
</tr>
</table>
<pre>
Consider the following code:
```
class A{
public:
A() : member_(0) {};
int member_;
};
class B : public A {};
int main(){
B *test;
return 0;
}
```
Because we only declare a pointer to B, clang++ only adds the following DWARF information for the type:
```
<1><47>: Abbrev Number: 6 (DW_TAG_class_type)
<48> DW_AT_name : (indexed string: 0x6): B
<49> DW_AT_declaration : 1
```
Despite having complete information about the type. Contrast with the result if we have declared `B test` instead:
```
<0><2b>: Abbrev Number: 2 (DW_TAG_class_type)
<2c> DW_AT_calling_convention: 5 (pass by value)
<2d> DW_AT_name : (indexed string: 0x6): B
<2e> DW_AT_byte_size : 4
<2f> DW_AT_decl_file : 0
<30> DW_AT_decl_line : 7
<1><31>: Abbrev Number: 3 (DW_TAG_inheritance)
<32> DW_AT_type : <0x42>
<36> DW_AT_data_member_location: 0
<37> DW_AT_accessibility: 1 (public)
<1><38>: Abbrev Number: 4 (DW_TAG_subprogram)
<39> DW_AT_name : (indexed string: 0x6): B
<3a> DW_AT_declaration : 1
<3a> DW_AT_artificial : 1
<3a> DW_AT_external : 1
<3a> DW_AT_accessibility: 1 (public)
<2><3b>: Abbrev Number: 5 (DW_TAG_formal_parameter)
<3c> DW_AT_type : <0x82>
<40> DW_AT_artificial : 1
<2><40>: Abbrev Number: 0
<1><41>: Abbrev Number: 0
```
This is a problem because GDB is unable to properly print the type or values of `test`, along with making it impossible to call on functions that take an A parameter with a *B variable, since we can't figure out the relationship between the two classes.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVk2PozgQ_TXkYm1kPkLCgQN0duY2h1FLc4x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