r178321 - [analyzer] Add static initializer test case (from <rdar://problem/13227740>).
Ted Kremenek
kremenek at apple.com
Thu Mar 28 17:32:36 PDT 2013
Author: kremenek
Date: Thu Mar 28 19:32:36 2013
New Revision: 178321
URL: http://llvm.org/viewvc/llvm-project?rev=178321&view=rev
Log:
[analyzer] Add static initializer test case (from <rdar://problem/13227740>).
Modified:
cfe/trunk/test/Analysis/retain-release.mm
Modified: cfe/trunk/test/Analysis/retain-release.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.mm?rev=178321&r1=178320&r2=178321&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.mm (original)
+++ cfe/trunk/test/Analysis/retain-release.mm Thu Mar 28 19:32:36 2013
@@ -64,6 +64,8 @@ extern const CFArrayCallBacks kCFTypeArr
typedef const struct __CFArray * CFArrayRef;
typedef struct __CFArray * CFMutableArrayRef;
extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks);
+void abort(void) __attribute__((noreturn));
+CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks);
extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value);
typedef struct {
@@ -385,3 +387,24 @@ void testCallback() {
val >> process;
}
+//===----------------------------------------------------------------------===//
+// Test handling static initializers.
+//===----------------------------------------------------------------------===//
+
+ at interface radar13227740 : NSObject
+ at end
+
+ at implementation radar13227740
+- (CFArrayRef)test {
+ static CFArrayRef array = ::CFArrayCreate(0, 0, 0, 0);
+ do { if (!((0 != array)/1)) { abort(); } } while (false);
+ return array;
+}
+
+// Previously this reported a bogus leak.
+- (void)test2 {
+ (void)[self test];
+ (void)[self test];
+}
+ at end
+
More information about the cfe-commits
mailing list