]> granicus.if.org Git - clang/commit
[CodeGen] Use the non-virtual alignment when emitting the base
authorAkira Hatanaka <ahatanaka@apple.com>
Sat, 27 Jan 2018 00:34:09 +0000 (00:34 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Sat, 27 Jan 2018 00:34:09 +0000 (00:34 +0000)
commitd145f4b8c34e0dcaa4ca860997a9970a92056a5f
tree36ae58fb4b5244bafc6db531ca3629d6fac19847
parentadf839121792511c0a431e78adfad8215ff428e1
[CodeGen] Use the non-virtual alignment when emitting the base
constructor.

Previously, clang would emit an over-aligned (16-byte) store to
initialize B::x in B's base constructor when compiling the following
code:

struct A {
  __attribute__((aligned(16))) double data1;
};

struct B : public virtual A {
  B() : x(123) {}
  double a;
  int x;
};

struct C : public virtual B {};

void test() { B b; C c; }

This was happening because the code in IRGen that does member
initialization was using the alignment of a complete object instead of
the non-virtual alignment.

This commit fixes the bug.

rdar://problem/36382481

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323578 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGClass.cpp
test/CodeGenCXX/virtual-bases.cpp