On Sep 18, 2013, at 1:52 PM, Eli Friedman <[email protected]> wrote:

> On Tue, Sep 17, 2013 at 8:08 PM, jahanian <[email protected]> wrote:
> Can you elaborate what got fixed. Are we matching gcc's behavior? I see that 
> it is
> currently ""{E=^^?i^^?ii^^?}" for this test case.
> 
> The patch fixes an assertion failure, and also nonsensical output when 
> assertions are turned off.  (The encoding is supposed to match the layout of 
> the class, and the class has two vptrs, not three.)

Ok. Thanks.
- Fariborz

> 
> -Eli
>  
> 
> - Fariborz
> 
> 
> On Sep 17, 2013, at 6:59 PM, Eli Friedman <[email protected]> wrote:
> 
> > 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);
> > +}
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > [email protected]
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 
> 

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to