Issue 58143
Summary Clang++ doesn't always add complete information for a class
Labels
Assignees
Reporter billionai
    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. 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to