[llvm] [llvm][DebugInfo] Allow anonymous basic types (PR #180016)

Tom Tromey via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 12 07:06:32 PST 2026


tromey wrote:

> Yea don't see why not.
> 
> Out of curiosity, what's a use-case for generating a `DW_AT_base_type` without a name?

I dug through a bunch of tests looking for our current workaround.  There are probably other cases but one is suppose you have a modular type that isn't a multiple of 8 bits:
```
   type Small is mod 2 ** 6;
```
Here gnat-llvm will emit a subrange type:
```
 <2><74>: Abbrev Number: 7 (DW_TAG_subrange_type)
    <75>   DW_AT_name        : (indirect string, offset: 0x7f): small
    <79>   DW_AT_type        : <0xbf>
...
    <81>   DW_AT_lower_bound : 0
    <82>   DW_AT_upper_bound : 63
```
but the underlying base type here doesn't have a name in the source code:
```
 <1><bf>: Abbrev Number: 3 (DW_TAG_base_type)
    <c0>   DW_AT_name        : (indirect string, offset: 0x85): pack__small___UMT
    <c4>   DW_AT_encoding    : 7	(unsigned)
    <c5>   DW_AT_byte_size   : 1
```

Ada's type system isn't really like C's so this kind of thing makes more sense.  I'd even like to be able to set the scope on base types (here you can see that `<1>` and the funny encoded name... this should really appear as a child of the the `pack` module), but that's a bit more of a pain to implement.

https://github.com/llvm/llvm-project/pull/180016


More information about the llvm-commits mailing list