]> granicus.if.org Git - clang/commitdiff
Fix a bug in objc @encoding of C++ classes.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 22 Aug 2011 16:03:14 +0000 (16:03 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 22 Aug 2011 16:03:14 +0000 (16:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138235 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/CodeGenObjCXX/encode.mm

index a731782a7ac6d0f2d0e2eb285fd61c4e931b5a22..1b2c5cf418760297e53d3cd63059fd21fa24838a 100644 (file)
@@ -4565,7 +4565,9 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
   std::multimap<uint64_t, NamedDecl *>::iterator
     CurLayObj = FieldOrBaseOffsets.begin();
 
-  if (CurLayObj != FieldOrBaseOffsets.end() && CurLayObj->first != 0) {
+  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 (FD) {
index 2c10fbcb97531634445681c516f83bba53aa04ab..677f5e2a7c42d33d6b2a1dc31d0784c6eb1bfe3f 100644 (file)
@@ -105,6 +105,27 @@ namespace rdar9624314 {
   const char g2[] = @encode(S2);
 }
 
+namespace test {
+  class Foo {
+  public:
+   virtual void f() {};
+  };
+  
+  class Bar {
+  public:
+   virtual void g() {};
+  };
+  
+  class Zoo : virtual public Foo, virtual public Bar {
+  public:
+   int x;
+   int y;
+  };
+
+  // CHECK: @_ZN4testL3ecdE = internal constant [15 x i8] c"{Zoo=^^?ii^^?}\00"
+  const char ecd[] = @encode(Zoo);
+}
+
 struct Base1 {
   char x;
 };