]> granicus.if.org Git - clang/commitdiff
[analyzer] Shorten ObjcSuperDeallocChecker diagnostics.
authorDevin Coughlin <dcoughlin@apple.com>
Fri, 26 Feb 2016 00:47:42 +0000 (00:47 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Fri, 26 Feb 2016 00:47:42 +0000 (00:47 +0000)
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".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261945 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
test/Analysis/DeallocUseAfterFreeErrors.m

index 263da2014656db74cbd6ed98540fef3cb96fbcb1..9c1d69d2fe26053c44276f2ec5e19314708fb069 100644 (file)
@@ -166,7 +166,7 @@ void ObjCSuperDeallocChecker::checkLocation(SVal L, bool IsLoad, const Stmt *S,
   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::reportUseAfterDealloc(SymbolRef Sym,
     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(
index 9ae9a96718c3b8691abe50340e9bfa60ef51023d..cfb202b6507da074e6bde62243e3625a69d90bc2 100644 (file)
@@ -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