[linters] Support transition Parameters also by ObjC method calls

Reviewed By: jvillard

Differential Revision: D5745582

fbshipit-source-id: 20b37f3
master
Dulma Churchill 7 years ago committed by Facebook Github Bot
parent 47088e078e
commit ecd79a56d3

@ -697,11 +697,13 @@ let transition_stmt_to_decl_via_pointer stmt =
| _
-> []
let transition_decl_to_decl_via_parameters dec =
let transition_via_parameters an =
let open Clang_ast_t in
match dec with
| ObjCMethodDecl (_, _, omdi)
match an with
| Decl ObjCMethodDecl (_, _, omdi)
-> List.map ~f:(fun d -> Decl d) omdi.omdi_parameters
| Stmt ObjCMessageExpr (_, stmt_list, _, _)
-> List.map ~f:(fun stmt -> Stmt stmt) stmt_list
| _
-> []
@ -739,8 +741,8 @@ let next_state_via_transition an trans =
match (an, trans) with
| Decl d, Super
-> transition_decl_to_decl_via_super d
| Decl d, Parameters
-> transition_decl_to_decl_via_parameters d
| _, Parameters
-> transition_via_parameters an
| Decl d, InitExpr | Decl d, Body
-> transition_decl_to_stmt d trans
| Decl d, Protocol

@ -4,8 +4,10 @@ codetoanalyze/objcpp/linters-for-test-only/ReferenceTest.mm, ReferenceTest_newWi
codetoanalyze/objcpp/linters-for-test-only/ReferenceTest.mm, ReferenceTest_newWithActionRef:, 40, TEST_REFERENCE, []
codetoanalyze/objcpp/linters-for-test-only/ReferenceTest.mm, ReferenceTest_newWithConstAction:, 21, TEST_REFERENCE, []
codetoanalyze/objcpp/linters-for-test-only/ReferenceTest.mm, ReferenceTest_newWithConstAction:, 36, TEST_REFERENCE, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, anotherButtonComponent, 36, PARAMETER_TRANS_TYPE, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, anotherButtonComponent, 36, TEST_PARAMETER_LABEL, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, anotherButtonComponent, 36, TEST_PARAMETER_LABEL_REGEXP, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, buttonComponent, 31, PARAMETER_TRANS_TYPE, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, buttonComponent, 31, TEST_PARAMETER_LABEL, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, buttonComponent, 31, TEST_PARAMETER_LABEL_EMPTY_MAP, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, buttonComponent, 31, TEST_PARAMETER_LABEL_EMPTY_STRUCT, []

@ -107,3 +107,11 @@ DEFINE-CHECKER DISCOURAGED_HASH_METHOD_INVOCATION = {
SET report_when = call_method("hash");
SET message = "Don't use the hash method";
};
DEFINE-CHECKER PARAMETER_TRANS_TYPE = {
SET report_when =
WHEN
HOLDS-NEXT WITH-TRANSITION Parameters (has_type("int"))
HOLDS-IN-NODE ObjCMessageExpr;
SET message = "Found method called with an argument of type int";
};

Loading…
Cancel
Save