[llvm] Add DISubrangeType (PR #126772)

Tom Tromey via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 12 07:05:01 PST 2025


tromey wrote:

> Could you share some examples of what these Ada types look like, how they're used and what the expected DWARF would look like?

Here's an example of a range type that shows some of the features:
```
   type Small is range -7 .. -4;
   for Small'Size use 2;
```
This is an integer range.  Objects of this type take 2 bits, so the type is stored with a bias -- that is, the value -7 is represented as 0 in memory.  It looks like this in the DWARF (this is the GCC output but the LLVM output is similar):
```
 <2><119e>: Abbrev Number: 4 (DW_TAG_subrange_type)
    <119f>   DW_AT_lower_bound : -7
    <11a0>   DW_AT_upper_bound : -4
    <11a1>   DW_AT_GNU_bias    : -7
    <11a2>   DW_AT_name        : (indirect string, offset: 0x1b2b): bias__small
    <11a6>   DW_AT_type        : <0x125a>
```

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


More information about the llvm-commits mailing list