forked from OSchip/llvm-project
Fix ObjC @encode for C++ classes w/virtual bases.
PR17142. llvm-svn: 190912
This commit is contained in:
parent
d25789a671
commit
1d24af872d
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue