r190912 - Fix ObjC @encode for C++ classes w/virtual bases.
Eli Friedman
eli.friedman at gmail.com
Tue Sep 17 18:59:16 PDT 2013
Author: efriedma
Date: Tue Sep 17 20:59:16 2013
New Revision: 190912
URL: http://llvm.org/viewvc/llvm-project?rev=190912&view=rev
Log:
Fix ObjC @encode for C++ classes w/virtual bases.
PR17142.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenObjCXX/encode.mm
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=190912&r1=190911&r2=190912&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Sep 17 20:59:16 2013
@@ -5552,7 +5552,8 @@ void ASTContext::getObjCEncodingForStruc
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));
}
Modified: cfe/trunk/test/CodeGenObjCXX/encode.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/encode.mm?rev=190912&r1=190911&r2=190912&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/encode.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/encode.mm Tue Sep 17 20:59:16 2013
@@ -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);
+}
More information about the cfe-commits
mailing list