[PATCH] D22929: [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 17 12:50:27 PDT 2016
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;
+};
+
+ at interface N
+{
+ S<N> a;
+}
+ at end
+
+ at implementation N
+ at 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22929.68400.patch
Type: text/x-patch
Size: 2307 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160817/c059829a/attachment-0001.bin>
More information about the cfe-commits
mailing list