[CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl.
Check that ExpandStructures is true before visiting the list of ivars.
rdar://problem/27135221
Differential revision: https://reviews.llvm.org/D22929
llvm-svn: 278956
diff --git a/clang/test/CodeGenObjCXX/encode.mm b/clang/test/CodeGenObjCXX/encode.mm
index e0171ef..6b7fc70 100644
--- a/clang/test/CodeGenObjCXX/encode.mm
+++ b/clang/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);
+}