[cfe-commits] r155738 - in /cfe/trunk: lib/AST/ASTContext.cpp test/CodeGenObjCXX/encode.mm
Douglas Gregor
dgregor at apple.com
Fri Apr 27 15:30:01 PDT 2012
Author: dgregor
Date: Fri Apr 27 17:30:01 2012
New Revision: 155738
URL: http://llvm.org/viewvc/llvm-project?rev=155738&view=rev
Log:
When @encode'ing a C++ class that has empty base classes, we can end
up with gaps when the class inherits from the same empty base class
more than once. Fixes <rdar://problem/11324167>.
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=155738&r1=155737&r2=155738&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Apr 27 17:30:01 2012
@@ -4787,11 +4787,8 @@
std::multimap<uint64_t, NamedDecl *>::iterator
CurLayObj = FieldOrBaseOffsets.begin();
- if ((CurLayObj != FieldOrBaseOffsets.end() && CurLayObj->first != 0) ||
- (CurLayObj == FieldOrBaseOffsets.end() &&
- CXXRec && CXXRec->isDynamicClass())) {
- assert(CXXRec && CXXRec->isDynamicClass() &&
- "Offset 0 was empty but no VTable ?");
+ if (CXXRec && CXXRec->isDynamicClass() &&
+ (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
if (FD) {
S += "\"_vptr$";
std::string recname = CXXRec->getNameAsString();
Modified: cfe/trunk/test/CodeGenObjCXX/encode.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/encode.mm?rev=155738&r1=155737&r2=155738&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/encode.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/encode.mm Fri Apr 27 17:30:01 2012
@@ -187,3 +187,17 @@
class CefBrowserImpl2 : public CefBrowser2 {};
// CHECK: @_ZL2g7 = internal constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00"
const char g7[] = @encode(CefBrowserImpl2);
+
+// <rdar://problem/11324167>
+struct Empty {};
+
+struct X : Empty {
+ int array[10];
+};
+
+struct Y : Empty {
+ X vec;
+};
+
+// CHECK: @_ZL2g8 = internal constant [14 x i8] c"{Y={X=[10i]}}\00"
+const char g8[] = @encode(Y);
More information about the cfe-commits
mailing list