
expression Clang emits invalid protocol metadata when a @protocol expression is used with a forward-declared protocol. The protocol metadata is missing protocol conformance list of the protocol since we don't have access to the definition of it in the compiled translation unit. The linker then might end up picking the invalid metadata when linking which will lead to incorrect runtime protocol conformance checks. This commit makes sure that Clang fails to compile code that uses a @protocol expression with a forward-declared protocol. This ensures that Clang does not emit invalid protocol metadata. I added an extra assert in CodeGen to ensure that this kind of issue won't happen in other places. rdar://32787811 Differential Revision: https://reviews.llvm.org/D49462 llvm-svn: 340102
29 lines
658 B
Objective-C
29 lines
658 B
Objective-C
// RUN: %clang -cc1 -triple thumbv7--windows-itanium -fobjc-runtime=ios -emit-llvm -o - %s -Wno-objc-root-class | FileCheck %s
|
|
|
|
@protocol P
|
|
- (void) method;
|
|
@end
|
|
|
|
@protocol Q @end
|
|
@protocol R @end
|
|
|
|
@interface I<P>
|
|
@end
|
|
|
|
@implementation I
|
|
- (void) method { }
|
|
@end
|
|
|
|
_Bool f(void) {
|
|
return @protocol(Q) == @protocol(R);
|
|
}
|
|
|
|
// CHECK: $"\01l_OBJC_PROTOCOL_$_P" = comdat any
|
|
// CHECK: $"\01l_OBJC_LABEL_PROTOCOL_$_P" = comdat any
|
|
// CHECK: $"\01l_OBJC_PROTOCOL_REFERENCE_$_Q" = comdat any
|
|
// CHECK: $"\01l_OBJC_PROTOCOL_REFERENCE_$_R" = comdat any
|
|
|
|
// CHECK: @"\01l_OBJC_PROTOCOL_$_P" = {{.*}}, comdat
|
|
// CHECK: @"\01l_OBJC_LABEL_PROTOCOL_$_P" = {{.*}}, comdat
|
|
|