[AST] Do not align virtual bases in `MicrosoftRecordLayoutBuilder` when
authorAleksandr Urakov <aleksandr.urakov@jetbrains.com>
Tue, 23 Oct 2018 08:23:22 +0000 (08:23 +0000)
committerAleksandr Urakov <aleksandr.urakov@jetbrains.com>
Tue, 23 Oct 2018 08:23:22 +0000 (08:23 +0000)
commit5c3d8fe8533f402f41eb79e85604af685b5c235a
tree3b1fb1e3bed6b0bc14cc2e407e3f73e78db97d8f
parentafe33a2725aaaf5005dfccb222b6f7c03e7a2695
[AST] Do not align virtual bases in `MicrosoftRecordLayoutBuilder` when
      an external layout is used

Summary:
The patch removes alignment of virtual bases when an external layout is used.
We have two cases:
- the external layout source has an information about virtual bases offsets,
  so we just use them;
- the external source has no information about virtual bases offsets. In this
  case we can't predict where the base will be located. If we will align it but
  there will be something like `#pragma pack(push, 1)` really, then likely our
  layout will not fit into the real structure size, and then some asserts will
  hit. The asserts look reasonable, so I don't think that we need to remove
  them. May be it would be better instead don't align fields / bases etc.
  (so treat it always as `#pragma pack(push, 1)`) when an external layout source
  is used but no info about a field location is presented.

This one is related to D49871

Reviewers: rnk, rsmith, zturner, mstorsjo, majnemer

Reviewed By: rnk

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D53497

llvm-svn: 345012
clang/lib/AST/RecordLayoutBuilder.cpp
clang/test/CodeGenCXX/Inputs/override-layout-packed-base.layout
clang/test/CodeGenCXX/override-layout-packed-base.cpp