<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57059>57059</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            LLDB virtual base layouting edge case in case of non-default alignment
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          siggi-alpheus
      </td>
    </tr>
</table>

<pre>
    I'm guessing this is more of a curiosity than a real issue, but given this code:
```
class Base1 {
 public:
  virtual ~Base1() {}

  int m1;
};

class alignas(64) Base2 {
 public:
  virtual ~Base2() {}
  int m2;
};

class Derived : public virtual Base1, public virtual Base2 {
 public:
  ~Derived() override {}
};

class Derived2 : public Derived {
 public:
  int array[14];
};

class Derived3 : public Derived {
 public:
  int array[15];
};

int main() {
  Derived2 derived2;
  Derived3 derived3;

  return 0;
}
```
Compiling with -fdump-record-layouts gives this layout:
```
*** Dumping AST Record Layout
         0 | class Derived3
         0 |   class Derived (primary base)
         0 |     (Derived vtable pointer)
         8 |   int[15] array
        72 |   class Base1 (virtual base)
        72 |     (Base1 vtable pointer)
        80 |     int m1
       128 |   class Base2 (virtual base)
       128 |     (Base2 vtable pointer)
       136 |     int m2
           | [sizeof=192, dsize=140, align=64,
           |  nvsize=68, nvalign=8]
```
where Base2 is aligned as expected on a 64 byte boundary. However because DWARF does not store the non-default alignment, LLDB can't reconstruct the position of the virtual base class correctly:
```
$ lldb a.out -b -o 'script print([str(vb) for vb in lldb.target.FindFirstType("Derived3").vbases]);'
(lldb) target create "a.out"
Current executable set to '/workspaces/thresher/a.out' (x86_64).
(lldb) script print([str(vb) for vb in lldb.target.FindFirstType("Derived3").vbases]);
['+72: (class Base1 {\npublic:\n    int m1;\n    virtual ~Base1();\n}) Base1', '+88: (class Base2 {\npublic:\n    int m2;\n    virtual ~Base2();\n}) Base2']
```

I see that DWARF5 has added a DW_AT_alignment attribute that would allow noting the non-default alignment, though it appears that clang doesn't yet emit it.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9Vl2P6jYQ_TXhZQRKHEjCAw8LFPVK-3S7Uh9XTjIQtyaObAeW_vqOHcPCLuy2qtRVtMQfZ-Z4Zs44papPix8Ry_ew69EY0e7ANsIAPXulEdQWOFS9FsoIe6I13tKERi5pi-kxYisoews7ccB2gFaqxih9iuJ1FD9FWRweP6wkNwaW3GACUb4cJqHrSymqCwbgILTtyUWU_-L3RqyI2Nwj8nUwHLaK1sI-idJgy61f3q9ccil2LTdkKJs6U84s-xcU2B0KwTn71vkaNYWnBjIfHF3Mh-Ot7s1_yY94BbOBmTqg1qLG2yh9zYhdU7qwfOzUnZdrzU_RbJlMo9n6nx49_S-OZl878kngor3KULByOWUdXi5IeCcW1tIPVoGK3Pa6hfjG9b2iXql9J6STzlHYBsbbut93Y42V0vVY8pPqrfECMYNAhqlHEolYeGBNZpzVp99e4Ke3Bs8DNDAMfzGdeQW38b67BeBDPbKi02LP9QlKqjeK3gMYuK1n1MHyUiJ0igKP-jOoCCBaPmcv5PJmX85uOIWewIqzAu4yuoA8owHzDZ_i_RChV1wvJ6z4RIN9R-MddKHBvqGRpNktDfYhauCXKWBG_IVqG6XrZM5cY6jdhBtOYzf0jYyGro2t7tqA9hAgWeEQ7eGMKZyQ7tXcsUHq9cM5RGiWlGluAN86rCy9K9f3symUJ4tQqr6tqWwm8Ks6IjUeKLHivUFY__70cwO1olpvlQVj3SViG6RRO65xy3tpB_t7pPoges_P6yVUnOSbW3CiaY3VfWU9qnPXjiDfdA-58XVWQsZIF4Sy8vRYUFOQsi6BT0g7MC5hrChtuam06CyQAhyRwoXeapf50rWRrdJwKClXHjuxXO_QTjairTdCG_ty6tA3HHZRHKN0zScHR824QFMFUOdg-ZlF4Qw504MtqOgWpVgSzhNz-KGd9HQgKhF8w6ofisrQdutJR2xzVPpP0_GKvLCNbTSaxtXbJljJXUm-Fd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