From: Devin Coughlin Date: Fri, 26 Feb 2016 00:47:42 +0000 (+0000) Subject: [analyzer] Shorten ObjcSuperDeallocChecker diagnostics. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7025a697597480f4aae15df9914a37c2279cb78;p=clang [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". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261945 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp index 263da20146..9c1d69d2fe 100644 --- a/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp @@ -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 BR( diff --git a/test/Analysis/DeallocUseAfterFreeErrors.m b/test/Analysis/DeallocUseAfterFreeErrors.m index 9ae9a96718..cfb202b650 100644 --- a/test/Analysis/DeallocUseAfterFreeErrors.m +++ b/test/Analysis/DeallocUseAfterFreeErrors.m @@ -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