This revision was automatically updated to reflect the committed changes. Closed by commit rL278956: [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl. (authored by ahatanak).
Changed prior to commit: https://reviews.llvm.org/D22929?vs=65969&id=68400#toc Repository: rL LLVM https://reviews.llvm.org/D22929 Files: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/test/CodeGenObjCXX/encode.mm Index: cfe/trunk/test/CodeGenObjCXX/encode.mm =================================================================== --- cfe/trunk/test/CodeGenObjCXX/encode.mm +++ cfe/trunk/test/CodeGenObjCXX/encode.mm @@ -224,3 +224,24 @@ // CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00" extern const char x[] = @encode(E); } + +// This test used to cause infinite recursion. +template<typename T> +struct S { + typedef T Ty; + Ty *t; +}; + +@interface N +{ + S<N> a; +} +@end + +@implementation N +@end + +const char *expand_struct() { + // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] c"{N={S<N>=^{N}}}\00" + return @encode(N); +} Index: cfe/trunk/lib/AST/ASTContext.cpp =================================================================== --- cfe/trunk/lib/AST/ASTContext.cpp +++ cfe/trunk/lib/AST/ASTContext.cpp @@ -5906,18 +5906,20 @@ ObjCInterfaceDecl *OI = T->castAs<ObjCObjectType>()->getInterface(); S += '{'; S += OI->getObjCRuntimeNameAsString(); - S += '='; - SmallVector<const ObjCIvarDecl*, 32> Ivars; - DeepCollectObjCIvars(OI, true, Ivars); - for (unsigned i = 0, e = Ivars.size(); i != e; ++i) { - const FieldDecl *Field = cast<FieldDecl>(Ivars[i]); - if (Field->isBitField()) - getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field); - else - getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD, - false, false, false, false, false, - EncodePointerToObjCTypedef, - NotEncodedT); + if (ExpandStructures) { + S += '='; + SmallVector<const ObjCIvarDecl*, 32> Ivars; + DeepCollectObjCIvars(OI, true, Ivars); + for (unsigned i = 0, e = Ivars.size(); i != e; ++i) { + const FieldDecl *Field = cast<FieldDecl>(Ivars[i]); + if (Field->isBitField()) + getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field); + else + getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD, + false, false, false, false, false, + EncodePointerToObjCTypedef, + NotEncodedT); + } } S += '}'; return;
Index: cfe/trunk/test/CodeGenObjCXX/encode.mm =================================================================== --- cfe/trunk/test/CodeGenObjCXX/encode.mm +++ cfe/trunk/test/CodeGenObjCXX/encode.mm @@ -224,3 +224,24 @@ // CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00" extern const char x[] = @encode(E); } + +// This test used to cause infinite recursion. +template<typename T> +struct S { + typedef T Ty; + Ty *t; +}; + +@interface N +{ + S<N> a; +} +@end + +@implementation N +@end + +const char *expand_struct() { + // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] c"{N={S<N>=^{N}}}\00" + return @encode(N); +} Index: cfe/trunk/lib/AST/ASTContext.cpp =================================================================== --- cfe/trunk/lib/AST/ASTContext.cpp +++ cfe/trunk/lib/AST/ASTContext.cpp @@ -5906,18 +5906,20 @@ ObjCInterfaceDecl *OI = T->castAs<ObjCObjectType>()->getInterface(); S += '{'; S += OI->getObjCRuntimeNameAsString(); - S += '='; - SmallVector<const ObjCIvarDecl*, 32> Ivars; - DeepCollectObjCIvars(OI, true, Ivars); - for (unsigned i = 0, e = Ivars.size(); i != e; ++i) { - const FieldDecl *Field = cast<FieldDecl>(Ivars[i]); - if (Field->isBitField()) - getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field); - else - getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD, - false, false, false, false, false, - EncodePointerToObjCTypedef, - NotEncodedT); + if (ExpandStructures) { + S += '='; + SmallVector<const ObjCIvarDecl*, 32> Ivars; + DeepCollectObjCIvars(OI, true, Ivars); + for (unsigned i = 0, e = Ivars.size(); i != e; ++i) { + const FieldDecl *Field = cast<FieldDecl>(Ivars[i]); + if (Field->isBitField()) + getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field); + else + getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD, + false, false, false, false, false, + EncodePointerToObjCTypedef, + NotEncodedT); + } } S += '}'; return;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits