[cfe-commits] r84569 - in /cfe/trunk: lib/Analysis/CFRefCount.cpp test/Analysis/refcnt_naming.m test/Analysis/retain-release.m
Ted Kremenek
kremenek at apple.com
Mon Oct 19 17:13:00 PDT 2009
Author: kremenek
Date: Mon Oct 19 19:13:00 2009
New Revision: 84569
URL: http://llvm.org/viewvc/llvm-project?rev=84569&view=rev
Log:
retain/release checker: allow 'new', 'copy', 'alloc', 'init' prefix to start before '_' when determining Cocoa fundamental rule.
Fixes: <rdar://problem/7265711>
Modified:
cfe/trunk/lib/Analysis/CFRefCount.cpp
cfe/trunk/test/Analysis/refcnt_naming.m
cfe/trunk/test/Analysis/retain-release.m
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=84569&r1=84568&r2=84569&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Mon Oct 19 19:13:00 2009
@@ -93,12 +93,14 @@
// Skip '_'.
if (*s == '_') {
if (InPossiblePrefix) {
+ // If we already have a convention, return it. Otherwise, skip
+ // the prefix as if it wasn't there.
+ if (C != NoConvention)
+ break;
+
InPossiblePrefix = false;
AtBeginning = true;
- // Discard whatever 'convention' we
- // had already derived since it occurs
- // in the prefix.
- C = NoConvention;
+ assert(C == NoConvention);
}
++s;
continue;
Modified: cfe/trunk/test/Analysis/refcnt_naming.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/refcnt_naming.m?rev=84569&r1=84568&r2=84569&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/refcnt_naming.m (original)
+++ cfe/trunk/test/Analysis/refcnt_naming.m Mon Oct 19 19:13:00 2009
@@ -15,7 +15,7 @@
-(NSObject*)photoCopy; // read as "photo Copy"
-(NSObject*)__blebPRCopy; // read as "bleb PRCopy"
-(NSObject*)__blebPRcopy; // read as "bleb P Rcopy"
--(NSObject*)new_theprefixdoesnotcount; // read as "theprefixdoesnotcount"
+-(NSObject*)new_theprefixdoescount; // read as "new theprefixdoescount"
-(NSObject*)newestAwesomeStuff; // read as "newest awesome stuff"
@end
@@ -49,7 +49,7 @@
[x photoCopy]; // expected-warning{{leak}}
[x __blebPRCopy]; // expected-warning{{leak}}
[x __blebPRcopy]; // no-warning
- [x new_theprefixdoesnotcount]; // no-warning
+ [x new_theprefixdoescount]; // expected-warning{{leak}}
[x newestAwesomeStuff]; // no-warning
}
Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=84569&r1=84568&r2=84569&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Mon Oct 19 19:13:00 2009
@@ -1098,6 +1098,28 @@
}
//===----------------------------------------------------------------------===//
+// <rdar://problem/7265711> allow 'new', 'copy', 'alloc', 'init' prefix to
+// start before '_' when determining Cocoa fundamental rule
+//
+// Previously the retain/release checker just skipped prefixes before the
+// first '_' entirely. Now the checker honors the prefix if it results in a
+// recognizable naming convention (e.g., 'new', 'init').
+//===----------------------------------------------------------------------===//
+
+ at interface RDar7265711 {}
+- (id) new_stuff;
+ at end
+
+void rdar7265711_a(RDar7265711 *x) {
+ id y = [x new_stuff]; // expected-warning{{leak}}
+}
+
+void rdar7265711_b(RDar7265711 *x) {
+ id y = [x new_stuff]; // no-warning
+ [y release];
+}
+
+//===----------------------------------------------------------------------===//
// <rdar://problem/7306898> clang thinks [NSCursor dragCopyCursor] returns a
// retained reference
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list