================
@@ -255,3 +255,32 @@ void R8261992_test(R8261992 *tc) {
*p = 0xDEADBEEF; // expected-warning{{null}}
}
+extern CFStringRef CFStringCreateCopy(CFAllocatorRef, CFStringRef)
__attribute__((cf_returns_retained));
+extern CFStringRef exampleString;
+CFStringRef GH19340_Strings[2][2];
+
+@interface GH19340_StringCache : NSObject {
+ CFStringRef strings[2];
+ CFStringRef moreStrings[2][2];
+}
+@end
+
+@implementation GH19340_StringCache
+- (CFStringRef)stringAtZ:(int)z {
+ if (!strings[z])
+ strings[z] = CFStringCreateCopy(kCFAllocatorDefault, exampleString);
+ return strings[z]; // no-warning
+}
+
+- (CFStringRef)stringAtX:(int)x y:(int)y {
+ if (!moreStrings[x][y])
+ moreStrings[x][y] = CFStringCreateCopy(kCFAllocatorDefault, exampleString);
+ return moreStrings[x][y]; // no-warning
+}
+
+- (CFStringRef)staticStringAtX:(int)x y:(int)y {
+ if (!GH19340_Strings[x][y])
+ GH19340_Strings[x][y] = CFStringCreateCopy(kCFAllocatorDefault,
exampleString);
+ return GH19340_Strings[x][y]; // no-warning
+}
----------------
steakhal wrote:
This doesn't seem to be trivial. Would deserve some comments.
https://github.com/llvm/llvm-project/pull/241058
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits