diff --git a/infer/src/clang/ctl_parser_types.ml b/infer/src/clang/ctl_parser_types.ml index c48172e3d..dd3d3b5e7 100644 --- a/infer/src/clang/ctl_parser_types.ml +++ b/infer/src/clang/ctl_parser_types.ml @@ -402,6 +402,8 @@ let rec pointer_type_equal p ap = match (p, ap) with | PointerType (_, qt), Pointer abs_ctype' | ObjCObjectPointerType (_, qt), Pointer abs_ctype' -> check_type_ptr qt.qt_type_ptr abs_ctype' + | PointerType (_, qt), BuiltIn _ + -> check_type_ptr qt.qt_type_ptr ap | _, _ -> display_equality_warning () ; false @@ -451,7 +453,9 @@ and c_type_equal c_type abs_ctype = match (c_type, abs_ctype) with | BuiltinType (_, bi), BuiltIn abi -> builtin_equal bi abi - | PointerType _, Pointer _ | ObjCObjectPointerType _, Pointer _ + | TypedefType (_, tdi), BuiltIn _ + -> check_type_ptr tdi.tti_child_type.qt_type_ptr abs_ctype + | PointerType _, BuiltIn _ | PointerType _, Pointer _ | ObjCObjectPointerType _, Pointer _ -> pointer_type_equal c_type abs_ctype | LValueReferenceType (_, qt), Reference abs_typ | RValueReferenceType (_, qt), Reference abs_typ -> check_type_ptr qt.qt_type_ptr abs_typ diff --git a/infer/tests/codetoanalyze/objc/linters-for-test-only/issues.exp b/infer/tests/codetoanalyze/objc/linters-for-test-only/issues.exp index 7b4475d02..608d88ee8 100644 --- a/infer/tests/codetoanalyze/objc/linters-for-test-only/issues.exp +++ b/infer/tests/codetoanalyze/objc/linters-for-test-only/issues.exp @@ -39,6 +39,8 @@ codetoanalyze/objc/linters-for-test-only/protocols.m, Foo_newWithD, 28, TEST_BUI codetoanalyze/objc/linters-for-test-only/protocols.m, Linters_dummy_method, 11, TEST_PROTOCOL_DEF_INHERITANCE, [] codetoanalyze/objc/linters-for-test-only/protocols.m, Linters_dummy_method, 14, TEST_PROTOCOL_DEF_INHERITANCE, [] codetoanalyze/objc/linters-for-test-only/protocols.m, Linters_dummy_method, 17, TEST_PROTOCOL_DEF_INHERITANCE, [] +codetoanalyze/objc/linters-for-test-only/sel.m, fooButtonComponent_newWithAction, 12, TEST_INSTANCE_TYPE, [] +codetoanalyze/objc/linters-for-test-only/sel.m, fooButtonComponent_newWithAction, 12, TEST_PARAMETER_SEL_TYPE, [] codetoanalyze/objc/linters-for-test-only/subclassing.m, A_foo, 13, TEST_BUILTIN_TYPE, [] codetoanalyze/objc/linters-for-test-only/subclassing.m, A_foo, 13, TEST_PARAM_TYPE_CHECK2, [] codetoanalyze/objc/linters-for-test-only/subclassing.m, A_foo, 13, TEST_RETURN_METHOD, [] diff --git a/infer/tests/codetoanalyze/objc/linters-for-test-only/linters_example.al b/infer/tests/codetoanalyze/objc/linters-for-test-only/linters_example.al index a92bb504b..da943f191 100644 --- a/infer/tests/codetoanalyze/objc/linters-for-test-only/linters_example.al +++ b/infer/tests/codetoanalyze/objc/linters-for-test-only/linters_example.al @@ -402,3 +402,15 @@ DEFINE-CHECKER ENUM_CONSTANTS_OF_ENUM = { HOLDS-IN-NODE VarDecl; SET message = "var %name% declared in function"; }; + +DEFINE-CHECKER TEST_PARAMETER_SEL_TYPE = { + + SET report_when = + WHEN + method_return_type("instancetype") AND + method_has_a_parameter_with_type("SEL") + HOLDS-IN-NODE ObjCMethodDecl; + + SET message = "Method has parameter of type SEL"; + + }; diff --git a/infer/tests/codetoanalyze/objc/linters-for-test-only/sel.m b/infer/tests/codetoanalyze/objc/linters-for-test-only/sel.m new file mode 100644 index 000000000..2379f784a --- /dev/null +++ b/infer/tests/codetoanalyze/objc/linters-for-test-only/sel.m @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2017 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +#include + +@interface fooButtonComponent : NSObject ++ (instancetype)newWithAction:(SEL)selector; +@end