summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevin Coughlin <dcoughlin@apple.com>2016-02-26 00:47:42 +0000
committerDevin Coughlin <dcoughlin@apple.com>2016-02-26 00:47:42 +0000
commit896dffe752deb25a44d2369a6e350f5e5fa2e05d (patch)
tree10254017e53a52ba04e3504f9b1dd53ec559e874
parentea5415fabb3a714ba54514c0b7c37b3551788b33 (diff)
downloadbcm5719-llvm-896dffe752deb25a44d2369a6e350f5e5fa2e05d.tar.gz
bcm5719-llvm-896dffe752deb25a44d2369a6e350f5e5fa2e05d.zip
[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". llvm-svn: 261945
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp4
-rw-r--r--clang/test/Analysis/DeallocUseAfterFreeErrors.m57
2 files changed, 37 insertions, 24 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
index 263da201465..9c1d69d2fe2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
+++ b/clang/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<BugReport> BR(
diff --git a/clang/test/Analysis/DeallocUseAfterFreeErrors.m b/clang/test/Analysis/DeallocUseAfterFreeErrors.m
index 9ae9a96718c..cfb202b6507 100644
--- a/clang/test/Analysis/DeallocUseAfterFreeErrors.m
+++ b/clang/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
OpenPOWER on IntegriCloud