[infer][clang] the nullable checker should not warn on Objective C method call when the receiver is nullable

Reviewed By: sblackshear

Differential Revision: D6228024

fbshipit-source-id: 90887dd
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent d85d185402
commit 8274453277

@ -24,9 +24,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
if Typ.Procname.is_java callee_pname then not (Typ.Procname.java_is_static callee_pname) if Typ.Procname.is_java callee_pname then not (Typ.Procname.java_is_static callee_pname)
else else
Option.exists Option.exists
~f:(fun attributes -> ~f:(fun attributes -> attributes.ProcAttributes.is_cpp_instance_method)
attributes.ProcAttributes.is_objc_instance_method
|| attributes.ProcAttributes.is_cpp_instance_method)
(Specs.proc_resolve_attributes callee_pname) (Specs.proc_resolve_attributes callee_pname)

@ -11,7 +11,7 @@
int* __nullable returnsNull(); int* __nullable returnsNull();
@interface T : NSObject @interface T : NSObject
- (void)assignUnnanotatedFieldToNullBad; - (NSObject* _Nullable)nullableMethod;
@end @end
@implementation T { @implementation T {
@ -83,23 +83,32 @@ int* __nullable returnsNull();
} }
} }
- (void)dereferenceNullableMethodBad { - (void)dereferenceNullableFunctionBad {
int* p = returnsNull(); int* p = returnsNull();
*p = 42; *p = 42;
} }
- (void)dereferenceNullableMethod1Ok { - (void)dereferenceNullableFunction1Ok {
int* p = returnsNull(); int* p = returnsNull();
if (p) { if (p) {
*p = 42; *p = 42;
} }
} }
- (void)dereferenceNullableMethod2Ok { - (void)dereferenceNullableFunction2Ok {
int* p = returnsNull(); int* p = returnsNull();
if (p != nil) { if (p != nil) {
*p = 42; *p = 42;
} }
} }
- (NSObject* _Nullable)nullableMethod {
return nil;
}
- (NSString*)dereferenceNullableMethodOkay {
NSObject* object = [self nullableMethod];
return [object description];
}
@end @end

@ -3,8 +3,8 @@ codetoanalyze/objc/checkers/Nullable.m, T_FP_dereferenceNonnullFieldAfterTestFor
codetoanalyze/objc/checkers/Nullable.m, T_assignNonnullFieldToNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is assigned null here] codetoanalyze/objc/checkers/Nullable.m, T_assignNonnullFieldToNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is assigned null here]
codetoanalyze/objc/checkers/Nullable.m, T_assignUnnanotatedFieldToNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is assigned null here] codetoanalyze/objc/checkers/Nullable.m, T_assignUnnanotatedFieldToNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is assigned null here]
codetoanalyze/objc/checkers/Nullable.m, T_dereferenceNullableFieldBad, 1, NULL_DEREFERENCE, [start of procedure dereferenceNullableFieldBad] codetoanalyze/objc/checkers/Nullable.m, T_dereferenceNullableFieldBad, 1, NULL_DEREFERENCE, [start of procedure dereferenceNullableFieldBad]
codetoanalyze/objc/checkers/Nullable.m, T_dereferenceNullableMethodBad, 2, NULLABLE_DEREFERENCE, [deference of &p,assignment of the nullable value,definition of returnsNull] codetoanalyze/objc/checkers/Nullable.m, T_dereferenceNullableFunctionBad, 2, NULLABLE_DEREFERENCE, [deference of &p,assignment of the nullable value,definition of returnsNull]
codetoanalyze/objc/checkers/Nullable.m, T_dereferenceNullableMethodBad, 2, NULL_DEREFERENCE, [start of procedure dereferenceNullableMethodBad,Skipping returnsNull(): function or method not found] codetoanalyze/objc/checkers/Nullable.m, T_dereferenceNullableFunctionBad, 2, NULL_DEREFERENCE, [start of procedure dereferenceNullableFunctionBad,Skipping returnsNull(): function or method not found]
codetoanalyze/objc/checkers/Nullable.m, T_dereferenceUnnanotatedFieldAfterTestForNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is compared to null here] codetoanalyze/objc/checkers/Nullable.m, T_dereferenceUnnanotatedFieldAfterTestForNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is compared to null here]
codetoanalyze/objc/checkers/Nullable.m, T_dereferenceUnnanotatedFieldAfterTestForNullBad, 2, NULL_DEREFERENCE, [start of procedure dereferenceUnnanotatedFieldAfterTestForNullBad,Condition is true] codetoanalyze/objc/checkers/Nullable.m, T_dereferenceUnnanotatedFieldAfterTestForNullBad, 2, NULL_DEREFERENCE, [start of procedure dereferenceUnnanotatedFieldAfterTestForNullBad,Condition is true]
codetoanalyze/objc/checkers/Nullable.m, T_testNonnullFieldForNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is compared to null here] codetoanalyze/objc/checkers/Nullable.m, T_testNonnullFieldForNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is compared to null here]

Loading…
Cancel
Save