[clang] [alpha.webkit.NoUnretainedMemberChecker] Recognize NS_REQUIRES_PROPERTY_DEFINITIONS (PR #141293)
Ziqing Luo via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 6 00:03:33 PDT 2025
================
@@ -64,3 +64,33 @@ void forceTmplToInstantiate(FooTmpl<SomeObj, CFMutableArrayRef>) {}
};
} // namespace ptr_to_ptr_to_retained
+
+ at interface AnotherObject : NSObject {
+ NSString *ns_string;
+ CFStringRef cf_string;
+ // expected-warning at -1{{Instance variable 'cf_string' in 'AnotherObject' is a retainable type 'CFStringRef'; member variables must be a RetainPtr}}
+}
+ at property(nonatomic, strong) NSString *prop_string1;
+ at property(nonatomic, assign) NSString *prop_string2;
+// expected-warning at -1{{Property 'prop_string2' in 'AnotherObject' is a raw pointer to retainable type 'NSString'; member variables must be a RetainPtr}}
+ at property(nonatomic, unsafe_unretained) NSString *prop_string3;
+// expected-warning at -1{{Property 'prop_string3' in 'AnotherObject' is a raw pointer to retainable type 'NSString'; member variables must be a RetainPtr}}
+ at property(nonatomic, readonly) NSString *prop_string4;
+ at end
+
+NS_REQUIRES_PROPERTY_DEFINITIONS
+ at interface NoSynthObject : NSObject {
+ NSString *ns_string;
+ CFStringRef cf_string;
+ // expected-warning at -1{{Instance variable 'cf_string' in 'NoSynthObject' is a retainable type 'CFStringRef'; member variables must be a RetainPtr}}
+}
+ at property(nonatomic, readonly, strong) NSString *prop_string1;
+ at property(nonatomic, readonly, strong) NSString *prop_string2;
----------------
ziqingluo-90 wrote:
Would it make sense to also test for `@property(nonatomic, assign)` and `@property(nonatomic, unsafe_unretained)`, like what you did few lines the above?
https://github.com/llvm/llvm-project/pull/141293
More information about the cfe-commits
mailing list