]> granicus.if.org Git - clang/commit
CodeGen: Don't crash when initializing pointer-to-member fields in bases
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 28 Sep 2014 06:39:30 +0000 (06:39 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 28 Sep 2014 06:39:30 +0000 (06:39 +0000)
commit3e25c0c78712b7311643daca8158ab33ad83ad59
tree88f8ac356adc936707966711bf736cdb1c5d8917
parent5ce2184600e4a36abd952695fa6579b1c15d58dd
CodeGen: Don't crash when initializing pointer-to-member fields in bases

Clang uses two types to talk about a C++ class, the
NonVirtualBaseLLVMType and the LLVMType.  Previously, we would allow one
of these to be packed and the other not.

This is problematic.  If both don't agree on a common subset of fields,
then routines like getLLVMFieldNo will point to the wrong field.  Solve
this by copying the 'packed'-ness of the complete type to the
non-virtual subobject.  For this to work, we need to take into account
the non-virtual subobject's size and alignment when we are computing the
layout of the complete object.

This fixes PR21089.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218577 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGRecordLayoutBuilder.cpp
test/CodeGenCXX/class-layout.cpp
test/CodeGenCXX/pointers-to-data-members.cpp
test/CodeGenCXX/pr18962.cpp