[linters] Add support for Cxx structs when querying types

Reviewed By: jvillard

Differential Revision: D5745746

fbshipit-source-id: 90b7a36
master
Dulma Churchill 7 years ago committed by Facebook Github Bot
parent ecd79a56d3
commit 47221ab273

@ -320,6 +320,8 @@ and c_type_equal c_type abs_ctype =
-> objc_object_type_equal c_type abs_ctype -> objc_object_type_equal c_type abs_ctype
| ObjCInterfaceType (_, pointer), TypeName ae | ObjCInterfaceType (_, pointer), TypeName ae
-> typename_equal pointer ae -> typename_equal pointer ae
| RecordType (_, pointer), TypeName ae
-> typename_equal pointer ae
| TypedefType (_, tdi), TypeName ae | TypedefType (_, tdi), TypeName ae
-> typename_equal tdi.tti_decl_ptr ae -> typename_equal tdi.tti_decl_ptr ae
| TypedefType (ti, _), ObjCGenProt _ -> ( | TypedefType (ti, _), ObjCGenProt _ -> (

@ -13,5 +13,7 @@ codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, buttonCo
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, buttonComponent, 31, TEST_PARAMETER_LABEL_EMPTY_STRUCT, [] codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, buttonComponent, 31, TEST_PARAMETER_LABEL_EMPTY_STRUCT, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, buttonComponent, 31, TEST_PARAMETER_LABEL_REGEXP, [] codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, buttonComponent, 31, TEST_PARAMETER_LABEL_REGEXP, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, foo, 54, TEST_PARAMETER_SELECTOR, [] codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, foo, 54, TEST_PARAMETER_SELECTOR, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, foo, 54, TEST_PARAMETER_SELECTOR_BY_TYPE, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, foo, 56, TEST_PARAMETER_SELECTOR, [] codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, foo, 56, TEST_PARAMETER_SELECTOR, []
codetoanalyze/objcpp/linters-for-test-only/TestParamterLabelsChecks.mm, foo, 56, TEST_PARAMETER_SELECTOR_BY_TYPE, []
codetoanalyze/objcpp/linters-for-test-only/hash_test.mm, std::hash_NSObject_*__operator(), 14, DISCOURAGED_HASH_METHOD_INVOCATION, [] codetoanalyze/objcpp/linters-for-test-only/hash_test.mm, std::hash_NSObject_*__operator(), 14, DISCOURAGED_HASH_METHOD_INVOCATION, []

@ -115,3 +115,27 @@ DEFINE-CHECKER PARAMETER_TRANS_TYPE = {
HOLDS-IN-NODE ObjCMessageExpr; HOLDS-IN-NODE ObjCMessageExpr;
SET message = "Found method called with an argument of type int"; SET message = "Found method called with an argument of type int";
}; };
DEFINE-CHECKER TEST_PARAMETER_SELECTOR_BY_TYPE = {
LET initialized_with_selector_expr =
WHEN (is_node("ObjCSelectorExpr") HOLDS-EVERYWHERE-NEXT) HOLDS-IN-NODE CXXConstructExpr;
LET materialized_with_selector_expr =
WHEN (initialized_with_selector_expr HOLDS-EVENTUALLY) HOLDS-IN-NODE CXXConstructExpr;
LET method_has_parameter_type =
WHEN
HOLDS-NEXT WITH-TRANSITION Parameters
(has_type("CKComponentAction") AND
(initialized_with_selector_expr OR
materialized_with_selector_expr))
HOLDS-IN-NODE ObjCMessageExpr;
SET report_when =
WHEN
method_has_parameter_type
AND call_method(REGEXP("^new.*:$"))
HOLDS-IN-NODE ObjCMessageExpr;
SET message = "Do not construct the Component action with a selector only...`";
};

Loading…
Cancel
Save