xref: /aosp_15_r20/external/clang/test/CodeGenObjC/debug-info-property-class-extension.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -S -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
2*67e74705SXin Li
3*67e74705SXin Li// Checks debug info for properties from class extensions for a few cases.
4*67e74705SXin Li
5*67e74705SXin Li
6*67e74705SXin Li// Readonly property in interface made readwrite in a category, with @impl
7*67e74705SXin Li// The interesting bit is that when the ivar debug info is generated, the corresponding
8*67e74705SXin Li// property is looked up and also gets debug info. If the debug info from the interface's
9*67e74705SXin Li// declaration and from the ivar doesn't match, this will end up with two DIObjCProperty
10*67e74705SXin Li// entries which would be bad.
11*67e74705SXin Li@interface FooROWithImpl
12*67e74705SXin Li// CHECK-NOT: !DIObjCProperty(name: "evolvingpropwithimpl"{{.*}}line: [[@LINE+1]]
13*67e74705SXin Li@property (readonly) int evolvingpropwithimpl;
14*67e74705SXin Li@end
15*67e74705SXin Li@interface FooROWithImpl ()
16*67e74705SXin Li// CHECK: !DIObjCProperty(name: "evolvingpropwithimpl"{{.*}}line: [[@LINE+1]]
17*67e74705SXin Li@property int evolvingpropwithimpl;
18*67e74705SXin Li@end
19*67e74705SXin Li@implementation FooROWithImpl
20*67e74705SXin Li@synthesize evolvingpropwithimpl = _evolvingpropwithimpl;
21*67e74705SXin Li@end
22*67e74705SXin Li
23*67e74705SXin Li
24*67e74705SXin Li// Simple property from a class extension:
25*67e74705SXin Li@interface Foo
26*67e74705SXin Li@end
27*67e74705SXin Li@interface Foo()
28*67e74705SXin Li// CHECK: !DIObjCProperty(name: "myprop"{{.*}}line: [[@LINE+1]]
29*67e74705SXin Li@property int myprop;
30*67e74705SXin Li@end
31*67e74705SXin Li// There's intentionally no @implementation for Foo, because that would
32*67e74705SXin Li// generate debug info for the property via the backing ivar.
33*67e74705SXin Li
34*67e74705SXin Li
35*67e74705SXin Li// Readonly property in interface made readwrite in a category:
36*67e74705SXin Li@interface FooRO
37*67e74705SXin Li// Shouldn't be here but in the class extension below.
38*67e74705SXin Li// CHECK-NOT: !DIObjCProperty(name: "evolvingprop"{{.*}}line: [[@LINE+1]]
39*67e74705SXin Li@property (readonly) int evolvingprop;
40*67e74705SXin Li@end
41*67e74705SXin Li@interface FooRO ()
42*67e74705SXin Li// CHECK: !DIObjCProperty(name: "evolvingprop"{{.*}}line: [[@LINE+1]]
43*67e74705SXin Li@property int evolvingprop;
44*67e74705SXin Li@end
45*67e74705SXin Li
46*67e74705SXin Li
47*67e74705SXin Li// This references types in this file to force emission of their debug info.
48*67e74705SXin Livoid foo(Foo *f, FooRO *g, FooROWithImpl* h) { }
49