From: Fariborz Jahanian Date: Tue, 23 Dec 2008 21:30:15 +0000 (+0000) Subject: Last patch, for now, to privde ObjC's encoding of types. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e1b16c2e5b2c02d76e60ff28d609eeb21a2eb71;p=clang Last patch, for now, to privde ObjC's encoding of types. We now pass all gcc's encoding compatibility tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61387 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index b9514f35a0..c5b451740a 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1859,6 +1859,16 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, return; } else if (PointeeTy->isObjCInterfaceType()) { + if (dyn_cast(PointeeTy.getTypePtr())) { + // Another historical/compatibility reason. + // We encode the underlying type which comes out as + // {...}; + S += '^'; + getObjCEncodingForTypeImpl(PointeeTy, S, + false, ExpandPointedToStructures, + NULL); + return; + } S += '@'; if (FD) { ObjCInterfaceDecl *OI = PointeeTy->getAsObjCInterfaceType()->getDecl(); diff --git a/test/CodeGenObjC/encode-test.m b/test/CodeGenObjC/encode-test.m index 0ae4f13c50..21cc5c2c0d 100644 --- a/test/CodeGenObjC/encode-test.m +++ b/test/CodeGenObjC/encode-test.m @@ -3,7 +3,8 @@ // RUN: grep -e "{Derived=#ib32b8b3b8sb16b8b8b2b8ccb6}" %t | count 1 && // RUN: grep -e "{B1=#@c}" %t | count 1 && // RUN: grep -e "v12@0:4\[3\[4{Test=i}]]8" %t | count 1 && -// RUN: grep -e "r^{S=i}" %t | count 1 +// RUN: grep -e "r^{S=i}" %t | count 1 && +// RUN: grep -e "\^{Object=#}" %t | count 1 @class Int1; @@ -75,11 +76,19 @@ struct Innermost { struct S { int iS; }; +@interface Object +{ + Class isa; +} +@end +typedef Object MyObj; + int main() { const char *en = @encode(Derived); const char *eb = @encode(B1); const char *es = @encode(const struct S *); const char *ec = @encode(const struct S); + const char *ee = @encode(MyObj *const); }