From e73f282213af5f7f9d705f512fb384ff1395edd5 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 23 Feb 2009 02:51:29 +0000 Subject: [PATCH] retain/release checker: For now don't track the retain count of NSWindow objects (opt for false negatives). llvm-svn: 65304 --- clang/lib/Analysis/CFRefCount.cpp | 6 +++++- clang/test/Analysis/NSWindow.m | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp index 0d5752d55bc7..3816c560b3b9 100644 --- a/clang/lib/Analysis/CFRefCount.cpp +++ b/clang/lib/Analysis/CFRefCount.cpp @@ -1130,8 +1130,12 @@ void RetainSummaryManager::InitializeMethodSummaries() { addNSObjectMethSummary(GetNullarySelector("autorelease", Ctx), Summ); // For NSWindow, allocated objects are (initially) self-owned. + // FIXME: For now we opt for false negatives with NSWindow, as these objects + // self-own themselves. However, they only do this once they are displayed. + // Thus, we need to track an NSWindow's display status. + // This is tracked in . RetainSummary *NSWindowSumm = - getPersistentSummary(RetEffect::MakeReceiverAlias(), SelfOwn); + getPersistentSummary(RetEffect::MakeReceiverAlias(), StopTracking); addInstMethSummary("NSWindow", NSWindowSumm, "initWithContentRect", "styleMask", "backing", "defer", NULL); diff --git a/clang/test/Analysis/NSWindow.m b/clang/test/Analysis/NSWindow.m index 93ab871e16f7..4cab918f50c4 100644 --- a/clang/test/Analysis/NSWindow.m +++ b/clang/test/Analysis/NSWindow.m @@ -69,7 +69,8 @@ void f2() { } void f2b() { - NSWindow *window = [[NSWindow alloc] // expected-warning{{leak}} + // FIXME: NSWindow doesn't own itself until it is displayed. + NSWindow *window = [[NSWindow alloc] // no-warning initWithContentRect:NSMakeRect(0,0,100,100) styleMask:NSTitledWindowMask|NSClosableWindowMask backing:NSBackingStoreBuffered