r262659 - [analyzer] ObjCDeallocChecker: Only check for nil-out when type is retainable.
Devin Coughlin via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 3 13:38:39 PST 2016
Author: dcoughlin
Date: Thu Mar 3 15:38:39 2016
New Revision: 262659
URL: http://llvm.org/viewvc/llvm-project?rev=262659&view=rev
Log:
[analyzer] ObjCDeallocChecker: Only check for nil-out when type is retainable.
This fixes a crash when setting a property of struct type in -dealloc.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
cfe/trunk/test/Analysis/DeallocMissingRelease.m
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=262659&r1=262658&r2=262659&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Thu Mar 3 15:38:39 2016
@@ -860,9 +860,13 @@ ObjCDeallocChecker::getValueReleasedByNi
if (!ReceiverVal.isValid())
return nullptr;
- // Is the first argument nil?
if (M.getNumArgs() == 0)
return nullptr;
+
+ if (!M.getArgExpr(0)->getType()->isObjCRetainableType())
+ return nullptr;
+
+ // Is the first argument nil?
SVal Arg = M.getArgSVal(0);
ProgramStateRef notNilState, nilState;
std::tie(notNilState, nilState) =
Modified: cfe/trunk/test/Analysis/DeallocMissingRelease.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DeallocMissingRelease.m?rev=262659&r1=262658&r2=262659&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/DeallocMissingRelease.m (original)
+++ cfe/trunk/test/Analysis/DeallocMissingRelease.m Thu Mar 3 15:38:39 2016
@@ -664,6 +664,25 @@ void ReleaseMe(id arg);
@end
#endif
+struct SomeStruct {
+ int f;
+};
+ at interface ZeroOutStructWithSetter : NSObject
+ @property(assign) struct SomeStruct s;
+ at end
+
+ at implementation ZeroOutStructWithSetter
+- (void)dealloc {
+ struct SomeStruct zeroedS;
+ zeroedS.f = 0;
+
+ self.s = zeroedS;
+#if NON_ARC
+ [super dealloc];
+#endif
+}
+ at end
+
#if NON_ARC
@interface ReleaseIvarInArray : NSObject {
NSObject *_array[3];
More information about the cfe-commits
mailing list