forked from OSchip/llvm-project
[analyzer] ObjCDeallocChecker: Only check for nil-out when type is retainable.
This fixes a crash when setting a property of struct type in -dealloc. llvm-svn: 262659
This commit is contained in:
parent
c1a7c97c1b
commit
578a20a82e
|
@ -860,9 +860,13 @@ ObjCDeallocChecker::getValueReleasedByNillingOut(const ObjCMethodCall &M,
|
||||||
if (!ReceiverVal.isValid())
|
if (!ReceiverVal.isValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Is the first argument nil?
|
|
||||||
if (M.getNumArgs() == 0)
|
if (M.getNumArgs() == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
if (!M.getArgExpr(0)->getType()->isObjCRetainableType())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
// Is the first argument nil?
|
||||||
SVal Arg = M.getArgSVal(0);
|
SVal Arg = M.getArgSVal(0);
|
||||||
ProgramStateRef notNilState, nilState;
|
ProgramStateRef notNilState, nilState;
|
||||||
std::tie(notNilState, nilState) =
|
std::tie(notNilState, nilState) =
|
||||||
|
|
|
@ -664,6 +664,25 @@ void ReleaseMe(id arg);
|
||||||
@end
|
@end
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct SomeStruct {
|
||||||
|
int f;
|
||||||
|
};
|
||||||
|
@interface ZeroOutStructWithSetter : NSObject
|
||||||
|
@property(assign) struct SomeStruct s;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ZeroOutStructWithSetter
|
||||||
|
- (void)dealloc {
|
||||||
|
struct SomeStruct zeroedS;
|
||||||
|
zeroedS.f = 0;
|
||||||
|
|
||||||
|
self.s = zeroedS;
|
||||||
|
#if NON_ARC
|
||||||
|
[super dealloc];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
#if NON_ARC
|
#if NON_ARC
|
||||||
@interface ReleaseIvarInArray : NSObject {
|
@interface ReleaseIvarInArray : NSObject {
|
||||||
NSObject *_array[3];
|
NSObject *_array[3];
|
||||||
|
|
Loading…
Reference in New Issue