1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s
2 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class -fobjc-arc %s
4 void clang_analyzer_eval(bool);
5 void clang_analyzer_checkInlined(bool);
8 @property (readonly) int &value;
11 @implementation IntWrapper
15 void testReferenceConsistency(IntWrapper *w) {
16 clang_analyzer_eval(w.value == w.value); // expected-warning{{TRUE}}
17 clang_analyzer_eval(&w.value == &w.value); // expected-warning{{TRUE}}
22 clang_analyzer_eval(w.value == 42); // expected-warning{{TRUE}}
25 void testReferenceAssignment(IntWrapper *w) {
27 clang_analyzer_eval(w.value == 42); // expected-warning{{TRUE}}
31 struct IntWrapperStruct {
35 @interface StructWrapper
36 @property IntWrapperStruct inner;
39 @implementation StructWrapper
43 void testConsistencyStruct(StructWrapper *w) {
44 clang_analyzer_eval(w.inner.value == w.inner.value); // expected-warning{{TRUE}}
46 int origValue = w.inner.value;
50 clang_analyzer_eval(w.inner.value == 42); // expected-warning{{TRUE}}
56 CustomCopy() : value(0) {}
57 CustomCopy(const CustomCopy &other) : value(other.value) {
58 clang_analyzer_checkInlined(true); // expected-warning{{TRUE}}
63 @interface CustomCopyWrapper
64 @property CustomCopy inner;
67 @implementation CustomCopyWrapper
71 void testConsistencyCustomCopy(CustomCopyWrapper *w) {
72 clang_analyzer_eval(w.inner.value == w.inner.value); // expected-warning{{TRUE}}
74 int origValue = w.inner.value;
78 clang_analyzer_eval(w.inner.value == 42); // expected-warning{{TRUE}}
81 @protocol NoDirectPropertyDecl
82 @property IntWrapperStruct inner;
84 @interface NoDirectPropertyDecl <NoDirectPropertyDecl>
86 @implementation NoDirectPropertyDecl
91 void testNoDirectPropertyDecl(NoDirectPropertyDecl *w) {
92 clang_analyzer_eval(w.inner.value == w.inner.value); // expected-warning{{TRUE}}
94 int origValue = w.inner.value;
98 clang_analyzer_eval(w.inner.value == 42); // expected-warning{{TRUE}}