From f50c7b469e1aedaff1812496efdedb819cb0225d Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Wed, 3 Jan 2018 15:34:58 -0800 Subject: [PATCH] [infer][nullable checkers] move the tests for the nullable checker in a dedicated subdirectory Summary: This subdirectory was only containing tests related to nullable on Objective C. Reviewed By: sblackshear Differential Revision: D6657654 fbshipit-source-id: 11003f2 --- Makefile | 2 +- .../codetoanalyze/objc/checkers/issues.exp | 44 ------------------- .../Nullable.m => nullable/Examples.m} | 0 .../objc/{checkers => nullable}/Makefile | 2 +- .../codetoanalyze/objc/nullable/issues.exp | 22 ++++++++++ 5 files changed, 24 insertions(+), 46 deletions(-) delete mode 100644 infer/tests/codetoanalyze/objc/checkers/issues.exp rename infer/tests/codetoanalyze/objc/{checkers/Nullable.m => nullable/Examples.m} (100%) rename infer/tests/codetoanalyze/objc/{checkers => nullable}/Makefile (80%) create mode 100644 infer/tests/codetoanalyze/objc/nullable/issues.exp diff --git a/Makefile b/Makefile index e69e53f18..5830b27e7 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ BUILD_SYSTEMS_TESTS += xcodebuild_no_xcpretty objc_getters_setters DIRECT_TESTS += \ objc_frontend objc_errors objc_linters objc_ioslints \ objcpp_frontend objcpp_linters objc_linters-for-test-only objcpp_linters-for-test-only \ - objc_linters-def-folder objc_checkers objc_liveness objc_uninit + objc_linters-def-folder objc_nullable objc_liveness objc_uninit ifneq ($(XCPRETTY),no) BUILD_SYSTEMS_TESTS += xcodebuild endif diff --git a/infer/tests/codetoanalyze/objc/checkers/issues.exp b/infer/tests/codetoanalyze/objc/checkers/issues.exp deleted file mode 100644 index 5d2455986..000000000 --- a/infer/tests/codetoanalyze/objc/checkers/issues.exp +++ /dev/null @@ -1,44 +0,0 @@ -codetoanalyze/objc/checkers/Nullable.m, T_FP_dereferenceNonnullFieldAfterTestForNullOkay, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is compared to null here] -codetoanalyze/objc/checkers/Nullable.m, T_FP_dereferenceNonnullFieldAfterTestForNullOkay, 2, NULL_DEREFERENCE, [start of procedure FP_dereferenceNonnullFieldAfterTestForNullOkay,Condition is true] -codetoanalyze/objc/checkers/Nullable.m, T_URLWithStringOkay, 2, DEAD_STORE, [Write of unused value] -codetoanalyze/objc/checkers/Nullable.m, T_URLWithStringOkay, 2, NULL_DEREFERENCE, [start of procedure URLWithStringOkay,Skipping URLWithString:: function or method not found] -codetoanalyze/objc/checkers/Nullable.m, T_addNullableObjectInMutableArrayBad, 2, NULLABLE_DEREFERENCE, [dereferencing the return of nullableMethod,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_addNullableObjectInMutableArrayBad, 2, NULL_DEREFERENCE, [start of procedure addNullableObjectInMutableArrayBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -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_createArrayByAddingNilBad, 2, NULLABLE_DEREFERENCE, [dereferencing the return of nullableMethod,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_createArrayByAddingNilBad, 2, NULL_DEREFERENCE, [start of procedure createArrayByAddingNilBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_dereferenceNullableFieldBad, 1, NULL_DEREFERENCE, [start of procedure dereferenceNullableFieldBad] -codetoanalyze/objc/checkers/Nullable.m, T_dereferenceNullableFunctionBad, 2, NULLABLE_DEREFERENCE, [dereference of &p,assignment of the nullable value,definition of returnsNull] -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, 2, NULL_DEREFERENCE, [start of procedure dereferenceUnnanotatedFieldAfterTestForNullBad,Condition is true] -codetoanalyze/objc/checkers/Nullable.m, T_indirectNullableKeyInNSDictionaryBad, 3, NULLABLE_DEREFERENCE, [dereference of &nullableKeyString,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_indirectNullableKeyInNSDictionaryBad, 3, PREMATURE_NIL_TERMINATION_ARGUMENT, [start of procedure indirectNullableKeyInNSDictionaryBad,start of procedure nullableMethod,return from a call to T_nullableMethod,Message description with receiver nil returns nil.] -codetoanalyze/objc/checkers/Nullable.m, T_insertNullableObjectInMutableArrayBad, 2, NULLABLE_DEREFERENCE, [dereferencing the return of nullableMethod,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_insertNullableObjectInMutableArrayBad, 2, NULL_DEREFERENCE, [start of procedure insertNullableObjectInMutableArrayBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableKeyInNSDictionaryBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableKey,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableKeyInNSDictionaryBad, 2, PREMATURE_NIL_TERMINATION_ARGUMENT, [start of procedure nullableKeyInNSDictionaryBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableKeyInNSDictionaryInitBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableKey,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableKeyInNSDictionaryInitBad, 2, PREMATURE_NIL_TERMINATION_ARGUMENT, [start of procedure nullableKeyInNSDictionaryInitBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableKeyInNSDictionaryInitLiteralBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableKey,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableKeyInNSDictionaryInitLiteralBad, 2, NULL_DEREFERENCE, [start of procedure nullableKeyInNSDictionaryInitLiteralBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableObjectInNSArrayBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableObject,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableObjectInNSArrayBad, 2, NULL_DEREFERENCE, [start of procedure nullableObjectInNSArrayBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableValueInNSDictionaryBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableValue,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableValueInNSDictionaryBad, 2, PREMATURE_NIL_TERMINATION_ARGUMENT, [start of procedure nullableValueInNSDictionaryBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableValueInNSDictionaryInitBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableValue,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableValueInNSDictionaryInitBad, 2, PREMATURE_NIL_TERMINATION_ARGUMENT, [start of procedure nullableValueInNSDictionaryInitBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableValueInNSDictionaryInitLiteralBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableValue,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_nullableValueInNSDictionaryInitLiteralBad, 2, NULL_DEREFERENCE, [start of procedure nullableValueInNSDictionaryInitLiteralBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_reassigningNullableObjectOkay, 1, DEAD_STORE, [Write of unused value] -codetoanalyze/objc/checkers/Nullable.m, T_secondElementNullableObjectInNSArrayBad, 3, NULLABLE_DEREFERENCE, [dereference of &nullableObject,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_secondElementNullableObjectInNSArrayBad, 3, NULL_DEREFERENCE, [start of procedure secondElementNullableObjectInNSArrayBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_setNullableObjectInDictionaryBad, 2, NULLABLE_DEREFERENCE, [dereferencing the return of nullableMethod,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, T_setNullableObjectInDictionaryBad, 2, NULL_DEREFERENCE, [start of procedure setNullableObjectInDictionaryBad,start of procedure nullableMethod,return from a call to T_nullableMethod] -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_testUnnanotatedFieldForNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is compared to null here] -codetoanalyze/objc/checkers/Nullable.m, callNullableMethodFromProtocolBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableObject,assignment of the nullable value,definition of nullableMethod] -codetoanalyze/objc/checkers/Nullable.m, callNullableMethodFromProtocolBad, 2, NULL_DEREFERENCE, [start of procedure callNullableMethodFromProtocolBad(),Skipping nullableMethod: function or method not found] -codetoanalyze/objc/checkers/Nullable.m, callNullableMethodFromProtocolBad, 2, PARAMETER_NOT_NULL_CHECKED, [start of procedure callNullableMethodFromProtocolBad(),Message nullableMethod with receiver nil returns nil.] -codetoanalyze/objc/checkers/Nullable.m, objc_blockT_DeadStoreFP_testUnnanotatedFieldInClosureBad_1, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is compared to null here] diff --git a/infer/tests/codetoanalyze/objc/checkers/Nullable.m b/infer/tests/codetoanalyze/objc/nullable/Examples.m similarity index 100% rename from infer/tests/codetoanalyze/objc/checkers/Nullable.m rename to infer/tests/codetoanalyze/objc/nullable/Examples.m diff --git a/infer/tests/codetoanalyze/objc/checkers/Makefile b/infer/tests/codetoanalyze/objc/nullable/Makefile similarity index 80% rename from infer/tests/codetoanalyze/objc/checkers/Makefile rename to infer/tests/codetoanalyze/objc/nullable/Makefile index a835fec46..2e46c0e91 100644 --- a/infer/tests/codetoanalyze/objc/checkers/Makefile +++ b/infer/tests/codetoanalyze/objc/nullable/Makefile @@ -9,7 +9,7 @@ TESTS_DIR = ../../.. ANALYZER = checkers CLANG_OPTIONS = -c -INFER_OPTIONS = --biabduction --suggest-nullable --check-nullable --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --debug-exceptions --no-default-checkers --suggest-nullable --check-nullable --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.m) diff --git a/infer/tests/codetoanalyze/objc/nullable/issues.exp b/infer/tests/codetoanalyze/objc/nullable/issues.exp new file mode 100644 index 000000000..31075d772 --- /dev/null +++ b/infer/tests/codetoanalyze/objc/nullable/issues.exp @@ -0,0 +1,22 @@ +codetoanalyze/objc/nullable/Examples.m, T_FP_dereferenceNonnullFieldAfterTestForNullOkay, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is compared to null here] +codetoanalyze/objc/nullable/Examples.m, T_addNullableObjectInMutableArrayBad, 2, NULLABLE_DEREFERENCE, [dereferencing the return of nullableMethod,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_assignNonnullFieldToNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is assigned null here] +codetoanalyze/objc/nullable/Examples.m, T_assignUnnanotatedFieldToNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is assigned null here] +codetoanalyze/objc/nullable/Examples.m, T_createArrayByAddingNilBad, 2, NULLABLE_DEREFERENCE, [dereferencing the return of nullableMethod,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_dereferenceNullableFunctionBad, 2, NULLABLE_DEREFERENCE, [dereference of &p,assignment of the nullable value,definition of returnsNull] +codetoanalyze/objc/nullable/Examples.m, T_dereferenceUnnanotatedFieldAfterTestForNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is compared to null here] +codetoanalyze/objc/nullable/Examples.m, T_indirectNullableKeyInNSDictionaryBad, 3, NULLABLE_DEREFERENCE, [dereference of &nullableKeyString,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_insertNullableObjectInMutableArrayBad, 2, NULLABLE_DEREFERENCE, [dereferencing the return of nullableMethod,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_nullableKeyInNSDictionaryBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableKey,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_nullableKeyInNSDictionaryInitBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableKey,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_nullableKeyInNSDictionaryInitLiteralBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableKey,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_nullableObjectInNSArrayBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableObject,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_nullableValueInNSDictionaryBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableValue,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_nullableValueInNSDictionaryInitBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableValue,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_nullableValueInNSDictionaryInitLiteralBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableValue,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_secondElementNullableObjectInNSArrayBad, 3, NULLABLE_DEREFERENCE, [dereference of &nullableObject,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_setNullableObjectInDictionaryBad, 2, NULLABLE_DEREFERENCE, [dereferencing the return of nullableMethod,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, T_testNonnullFieldForNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is compared to null here] +codetoanalyze/objc/nullable/Examples.m, T_testUnnanotatedFieldForNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is compared to null here] +codetoanalyze/objc/nullable/Examples.m, callNullableMethodFromProtocolBad, 2, NULLABLE_DEREFERENCE, [dereference of &nullableObject,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/objc/nullable/Examples.m, objc_blockT_DeadStoreFP_testUnnanotatedFieldInClosureBad_1, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is compared to null here]