Author: dcoughlin
Date: Thu Feb 25 18:47:42 2016
New Revision: 261945

URL: http://llvm.org/viewvc/llvm-project?rev=261945&view=rev
Log:
[analyzer] Shorten ObjcSuperDeallocChecker diagnostics.

Change "use of 'self' after it has been freed with call to [super dealloc]" to
"use of 'self' after it has been deallocated" and "use of instance variable
'_ivar' after the instance has been freed with call to [super dealloc]" to
"use of instance variable '_ivar' after 'self' has been deallocated".

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
    cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp?rev=261945&r1=261944&r2=261945&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp Thu Feb 
25 18:47:42 2016
@@ -166,7 +166,7 @@ void ObjCSuperDeallocChecker::checkLocat
   llvm::raw_string_ostream OS(Buf);
   if (IvarRegion) {
     OS << "use of instance variable '" << *IvarRegion->getDecl() <<
-          "' after the instance has been freed with call to [super dealloc]";
+          "' after 'self' has been deallocated";
     Desc = OS.str();
   }
 
@@ -189,7 +189,7 @@ void ObjCSuperDeallocChecker::reportUseA
     return;
 
   if (Desc.empty())
-    Desc = "use of 'self' after it has been freed with call to [super 
dealloc]";
+    Desc = "use of 'self' after it has been deallocated";
 
   // Generate the report.
   std::unique_ptr<BugReport> BR(

Modified: cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m?rev=261945&r1=261944&r2=261945&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m (original)
+++ cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m Thu Feb 25 18:47:42 2016
@@ -36,8 +36,8 @@ typedef struct objc_selector *SEL;
 }
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  [_ivar release]; // expected-warning {{use of instance variable '_ivar' 
after the instance has been freed with call to [super dealloc]}}
-  // expected-note@-1 {{use of instance variable '_ivar' after the instance 
has been freed with call to [super dealloc]}}
+  [_ivar release]; // expected-warning {{use of instance variable '_ivar' 
after 'self' has been deallocated}}
+  // expected-note@-1 {{use of instance variable '_ivar' after 'self' has been 
deallocated}}
 }
 @end
 
@@ -56,8 +56,8 @@ typedef struct objc_selector *SEL;
 }
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  _delegate = nil; // expected-warning {{use of instance variable '_delegate' 
after the instance has been freed with call to [super dealloc]}}
-      // expected-note@-1 {{use of instance variable '_delegate' after the 
instance has been freed with call to [super dealloc]}}
+  _delegate = nil; // expected-warning {{use of instance variable '_delegate' 
after 'self' has been deallocated}}
+      // expected-note@-1 {{use of instance variable '_delegate' after 'self' 
has been deallocated}}
 }
 @end
 
@@ -74,8 +74,8 @@ struct SomeStruct {
 @implementation SuperDeallocThenAssignIvarField
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  _s.f = 7; // expected-warning {{use of instance variable '_s' after the 
instance has been freed with call to [super dealloc]}}
-      // expected-note@-1 {{use of instance variable '_s' after the instance 
has been freed with call to [super dealloc]}}
+  _s.f = 7; // expected-warning {{use of instance variable '_s' after 'self' 
has been deallocated}}
+      // expected-note@-1 {{use of instance variable '_s' after 'self' has 
been deallocated}}
 }
 @end
 
@@ -93,8 +93,21 @@ struct SomeStruct {
 @implementation SuperDeallocThenAssignIvarIvar
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  _ivar->_otherIvar = 7; // expected-warning {{use of instance variable 
'_ivar' after the instance has been freed with call to [super dealloc]}}
-      // expected-note@-1 {{use of instance variable '_ivar' after the 
instance has been freed with call to [super dealloc]}}
+  _ivar->_otherIvar = 7; // expected-warning {{use of instance variable 
'_ivar' after 'self' has been deallocated}}
+      // expected-note@-1 {{use of instance variable '_ivar' after 'self' has 
been deallocated}}
+}
+@end
+
+@interface SuperDeallocThenAssignSelfIvar : NSObject {
+  NSObject *_ivar;
+}
+@end
+
+@implementation SuperDeallocThenAssignSelfIvar
+- (void)dealloc {
+  [super dealloc]; // expected-note {{[super dealloc] called here}}
+  self->_ivar = nil; // expected-warning {{use of instance variable '_ivar' 
after 'self' has been deallocated}}
+      // expected-note@-1 {{use of instance variable '_ivar' after 'self' has 
been deallocated}}
 }
 @end
 
@@ -112,8 +125,8 @@ struct SomeStruct {
 }
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  self.ivar = nil; // expected-warning {{use of 'self' after it has been freed 
with call to [super dealloc]}}
-      // expected-note@-1 {{use of 'self' after it has been freed with call to 
[super dealloc]}}
+  self.ivar = nil; // expected-warning {{use of 'self' after it has been 
deallocated}}
+      // expected-note@-1 {{use of 'self' after it has been deallocated}}
 }
 @end
 
@@ -131,8 +144,8 @@ struct SomeStruct {
 }
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  self.delegate = nil; // expected-warning {{use of 'self' after it has been 
freed with call to [super dealloc]}}
-      // expected-note@-1 {{use of 'self' after it has been freed with call to 
[super dealloc]}}
+  self.delegate = nil; // expected-warning {{use of 'self' after it has been 
deallocated}}
+      // expected-note@-1 {{use of 'self' after it has been deallocated}}
 }
 @end
 
@@ -145,8 +158,8 @@ struct SomeStruct {
 }
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  [self _invalidate]; // expected-warning {{use of 'self' after it has been 
freed with call to [super dealloc]}}
-      // expected-note@-1 {{use of 'self' after it has been freed with call to 
[super dealloc]}}
+  [self _invalidate]; // expected-warning {{use of 'self' after it has been 
deallocated}}
+      // expected-note@-1 {{use of 'self' after it has been deallocated}}
 }
 @end
 
@@ -160,8 +173,8 @@ static void _invalidate(NSObject *object
 @implementation SuperDeallocThenCallNonObjectiveCMethodClass
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  _invalidate(self); // expected-warning {{use of 'self' after it has been 
freed with call to [super dealloc]}}
-      // expected-note@-1 {{use of 'self' after it has been freed with call to 
[super dealloc]}}
+  _invalidate(self); // expected-warning {{use of 'self' after it has been 
deallocated}}
+      // expected-note@-1 {{use of 'self' after it has been deallocated}}
 }
 @end
 
@@ -174,8 +187,8 @@ static void _invalidate(NSObject *object
 
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  [SuperDeallocThenCallObjectiveClassMethodClass invalidate:self]; // 
expected-warning {{use of 'self' after it has been freed with call to [super 
dealloc]}}
-      // expected-note@-1 {{use of 'self' after it has been freed with call to 
[super dealloc]}}
+  [SuperDeallocThenCallObjectiveClassMethodClass invalidate:self]; // 
expected-warning {{use of 'self' after it has been deallocated}}
+      // expected-note@-1 {{use of 'self' after it has been deallocated}}
 }
 @end
 
@@ -195,8 +208,8 @@ static void _invalidate(NSObject *object
     return;
   }
   [super dealloc];    // expected-note {{[super dealloc] called here}}
-  [self _invalidate]; // expected-warning {{use of 'self' after it has been 
freed with call to [super dealloc]}}
-      // expected-note@-1 {{use of 'self' after it has been freed with call to 
[super dealloc]}}
+  [self _invalidate]; // expected-warning {{use of 'self' after it has been 
deallocated}}
+      // expected-note@-1 {{use of 'self' after it has been deallocated}}
 }
 @end
 
@@ -353,8 +366,8 @@ static void _invalidate(NSObject *object
 
 - (void)dealloc; {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  [self anotherMethod]; // expected-warning {{use of 'self' after it has been 
freed with call to [super dealloc]}}
-      // expected-note@-1 {{use of 'self' after it has been freed with call to 
[super dealloc]}}
+  [self anotherMethod]; // expected-warning {{use of 'self' after it has been 
deallocated}}
+      // expected-note@-1 {{use of 'self' after it has been deallocated}}
   [super dealloc];
 }
 @end


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to