From cb8061e321bc6f46f154529885028256c7ae1fb2 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 22 Aug 2011 16:03:14 +0000 Subject: [PATCH] Fix a bug in objc @encoding of C++ classes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138235 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTContext.cpp | 4 +++- test/CodeGenObjCXX/encode.mm | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a731782a7a..1b2c5cf418 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -4565,7 +4565,9 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl, std::multimap::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) { diff --git a/test/CodeGenObjCXX/encode.mm b/test/CodeGenObjCXX/encode.mm index 2c10fbcb97..677f5e2a7c 100644 --- a/test/CodeGenObjCXX/encode.mm +++ b/test/CodeGenObjCXX/encode.mm @@ -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; }; -- 2.40.0