clang currently emits different strings for s0 and s1 in the following code because pointers to typedefs are encoded as "^{PointeeClassName=#}" while ObjC pointer types that aren't pointers to typedefs are encoded as "@".
@class Class1; typedef NSArray<Class1 *> MyArray; void foo1(void) { const char *s0 = @encode(MyArray *); // "^{NSArray=#}" const char *s1 = @encode(NSArray<Class1 *> *); // "@" }
It seems that this was a deliberate choice made in r61387 to make clang compatible with gcc (see http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20081222/010465.html), but it causes apple's runtime to crash. This patch fixes the bug by checking whether the runtime is one of the GNU runtimes before using the special encoding for typedefs.
rdar://problem/50563529
Please can we at least make this check just for the GCC runtime? I'm not sure it's even needed there. I've previously had to write code that works around this and have always considered it a bug in GCC, rather than a feature that I'd like us to copy, so I'd also be happy with just deleting this code path entirely.