mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 17:16:07 +00:00

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
14 lines
276 B
Objective-C
14 lines
276 B
Objective-C
// RUN: %clang -S -emit-llvm %s -o - -x objective-c -fobjc-runtime=gnustep-1.5 | FileCheck %s
|
|
|
|
// Regression test: check that we don't crash when referencing a forward-declared protocol.
|
|
@protocol P;
|
|
|
|
@interface I <P>
|
|
@end
|
|
|
|
@implementation I
|
|
|
|
@end
|
|
|
|
// CHECK: @.objc_protocol
|