[clang] [alpha.webkit.NoUnretainedMemberChecker] Only check @property when @implementation is seen (PR #159947)

Ryosuke Niwa via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 24 19:04:00 PDT 2025


================
@@ -84,6 +84,21 @@ @interface AnotherObject : NSObject {
 @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}}
 @property(nonatomic, readonly) NSString *prop_string4;
+ at property(nonatomic, readonly) NSString *prop_safe;
+ at end
+
+ at implementation AnotherObject
+- (NSString *)prop_safe {
+  return nil;
+}
+ at end
+
+// No warnings for @interface declaration itself. 
+ at interface InterfaceOnlyObject : NSObject
+ at property(nonatomic, strong) NSString *prop_string1;
+ at property(nonatomic, assign) NSString *prop_string2;
+ at property(nonatomic, unsafe_unretained) NSString *prop_string3;
+ at property(nonatomic, readonly) NSString *prop_string4;
----------------
rniwa wrote:

Actually, that's not really a bug since we don't auto-synthesize a property on a superclass. I added one more test case to test this exact scenario.

https://github.com/llvm/llvm-project/pull/159947


More information about the cfe-commits mailing list