Fix ObjC @encode for C++ classes w/virtual bases.

PR17142.

llvm-svn: 190912
This commit is contained in:
Eli Friedman 2013-09-18 01:59:16 +00:00
parent d25789a671
commit 1d24af872d
2 changed files with 12 additions and 1 deletions

View File

@ -5552,7 +5552,8 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
if (base->isEmpty())
continue;
uint64_t offs = toBits(layout.getVBaseClassOffset(base));
if (FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
if (offs >= uint64_t(toBits(layout.getNonVirtualSize())) &&
FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
std::make_pair(offs, base));
}

View File

@ -214,3 +214,13 @@ public:
}
@end
// CHECK: internal global [41 x i8] c"{dynamic_class=\22_vptr$dynamic_class\22^^?}\00"
namespace PR17142 {
struct A { virtual ~A(); };
struct B : virtual A { int y; };
struct C { virtual ~C(); int z; };
struct D : C, B { int a; };
struct E : D {};
// CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00"
extern const char x[] = @encode(E);
}