
Some ObjC users declare a extern variable named OBJC_CLASS_$_Foo, then use it's address as a Class. I.e., one could define isInstanceOfF: BOOL isInstanceOfF(id c) { extern void OBJC_CLASS_$_F; return [c class] == (Class)&OBJC_CLASS_$_F; } This leads to asserts in clang CodeGen if there is an @implementation of F in the same TU as an instance of this pattern, because CodeGen assumes that a variable named OBJC_CLASS_$_* has the right type. This commit fixes the problem by RAUWing the old (incorrectly typed) global with a new global, then removing the old global. rdar://45077269 Differential revision: https://reviews.llvm.org/D53154 llvm-svn: 344373
15 lines
433 B
Objective-C
15 lines
433 B
Objective-C
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -emit-llvm -o - | FileCheck %s
|
|
|
|
// rdar://45077269
|
|
|
|
extern void OBJC_CLASS_$_f;
|
|
Class c = (Class)&OBJC_CLASS_$_f;
|
|
|
|
@implementation f @end
|
|
|
|
// Check that we override the initializer for c, and that OBJC_CLASS_$_f gets
|
|
// the right definition.
|
|
|
|
// CHECK: @c = global i8* bitcast (%struct._class_t* @"OBJC_CLASS_$_f" to i8*)
|
|
// CHECK: @"OBJC_CLASS_$_f" = global %struct._class_t
|