[cfe-commits] r125130 - in /cfe/trunk: lib/StaticAnalyzer/Core/CFRefCount.cpp test/Analysis/refcnt_naming.m
Ted Kremenek
kremenek at apple.com
Tue Feb 8 14:54:26 PST 2011
Author: kremenek
Date: Tue Feb 8 16:54:26 2011
New Revision: 125130
URL: http://llvm.org/viewvc/llvm-project?rev=125130&view=rev
Log:
analyzer, retain/release checker: Remove hack where objects passed in message to 'self' are no longer tracked.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CFRefCount.cpp
cfe/trunk/test/Analysis/refcnt_naming.m
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CFRefCount.cpp?rev=125130&r1=125129&r2=125130&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CFRefCount.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CFRefCount.cpp Tue Feb 8 16:54:26 2011
@@ -1385,24 +1385,6 @@
// FIXME: The receiver could be a reference to a class, meaning that
// we should use the class method.
RetainSummary *Summ = getInstanceMethodSummary(msg, ID);
-
- // Special-case: are we sending a mesage to "self"?
- // This is a hack. When we have full-IP this should be removed.
- if (isa<ObjCMethodDecl>(LC->getDecl()) && Receiver) {
- if (const loc::MemRegionVal *L = dyn_cast<loc::MemRegionVal>(&receiverV)) {
- // Get the region associated with 'self'.
- if (const ImplicitParamDecl *SelfDecl = LC->getSelfDecl()) {
- SVal SelfVal = state->getSVal(state->getRegion(SelfDecl, LC));
- if (L->StripCasts() == SelfVal.getAsRegion()) {
- // Update the summary to make the default argument effect
- // 'StopTracking'.
- Summ = copySummary(Summ);
- Summ->setDefaultArgEffect(StopTracking);
- }
- }
- }
- }
-
return Summ ? Summ : getDefaultSummary();
}
Modified: cfe/trunk/test/Analysis/refcnt_naming.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/refcnt_naming.m?rev=125130&r1=125129&r2=125130&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/refcnt_naming.m (original)
+++ cfe/trunk/test/Analysis/refcnt_naming.m Tue Feb 8 16:54:26 2011
@@ -30,7 +30,9 @@
}
- (NSURL *)myMethod:(NSString *)inString;
- (NSURL *)getMethod:(NSString*)inString;
-- (void)addObject:(id)X;
+- (NSURL *)getMethod2:(NSString*)inString;
+- (void)addObject:(id) __attribute__((ns_consumed)) X;
+- (void)addObject2:(id) X;
@end
@implementation MyClass
@@ -48,6 +50,13 @@
return url; // no-warning
}
+- (NSURL *)getMethod2:(NSString *)inString
+{
+ NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); // expected-warning{{leak}}
+ [self addObject2:url];
+ return url;
+}
+
void testNames(NamingTest* x) {
[x copyPhoto]; // expected-warning{{leak}}
[x mutableCopyPhoto]; // expected-warning{{leak}}
@@ -67,4 +76,10 @@
myObject = X;
}
+- (void)addObject2:(id)X
+{
+ myObject = X;
+}
+
@end
+
More information about the cfe-commits
mailing list