[AL] Allow to match typedefs and pointers.

Differential Revision: D18779850

fbshipit-source-id: 9a0b09446
master
Dulma Churchill 5 years ago committed by Facebook Github Bot
parent fbe1c92c17
commit d00d8b3597

@ -558,7 +558,8 @@ and c_type_equal c_type abs_ctype =
| ElaboratedType ti, TypeName _ | ElaboratedType ti, TypeName _
| AutoType ti, TypeName _ | AutoType ti, TypeName _
| TypedefType (ti, _), ObjCGenProt _ | TypedefType (ti, _), ObjCGenProt _
| AttributedType (ti, _), Pointer _ -> ( | AttributedType (ti, _), Pointer _
| TypedefType (ti, _), Pointer _ -> (
match ti.ti_desugared_type with Some dt -> check_type_ptr dt abs_ctype | None -> false ) match ti.ti_desugared_type with Some dt -> check_type_ptr dt abs_ctype | None -> false )
| AttributedType (ti, _), TypeName _ -> ( | AttributedType (ti, _), TypeName _ -> (
match ti.ti_desugared_type with Some dt -> check_type_ptr dt abs_ctype | None -> false ) match ti.ti_desugared_type with Some dt -> check_type_ptr dt abs_ctype | None -> false )

@ -9,6 +9,9 @@
static CFStringRef CreateFoo() { static CFStringRef CreateFoo() {
return CFStringCreateWithCString(NULL, "Hello", kCFStringEncodingUTF8); return CFStringCreateWithCString(NULL, "Hello", kCFStringEncodingUTF8);
} }
static _Nullable CFStringRef CreateNullableFoo() {
return CFStringCreateWithCString(NULL, "Hello", kCFStringEncodingUTF8);
}
static void doSomething(CFStringRef s) { CFShow(s); } static void doSomething(CFStringRef s) { CFShow(s); }
@ -18,7 +21,7 @@ static void Foo() {}
int main() { int main() {
doSomething(CreateFoo()); doSomething(CreateFoo());
doSomethingElse(0, CreateFoo()); doSomethingElse(0, CreateNullableFoo());
Foo(); Foo();
return 0; return 0;
} }

@ -890,8 +890,8 @@ DEFINE-CHECKER IVAR_CAPTURED_IN_OBJC_BLOCK = {
}; };
DEFINE-CHECKER CALLS_TO_FUNCTIONS_WITH_CREATE_FUNCTION_PARAMETERS = { DEFINE-CHECKER CALLS_TO_FUNCTIONS_WITH_CREATE_FUNCTION_PARAMETERS = {
LET is_create_method_parameter = HOLDS-NEXT WITH-TRANSITION Parameters LET is_create_method_parameter = HOLDS-NEXT WITH-TRANSITION Parameters
(call_function(REGEXP(".*Create.*")) AND has_type("REGEXP('C.*Ref')")); (call_function(REGEXP(".*Create.*")) AND has_type("REGEXP('__C.+')*"));
SET report_when = SET report_when =
WHEN WHEN
is_create_method_parameter is_create_method_parameter
@ -915,7 +915,7 @@ DEFINE-CHECKER CLASS_AND_VAR = {
DEFINE-CHECKER CAT_DECL_MACRO = { DEFINE-CHECKER CAT_DECL_MACRO = {
LET is_linkable_var = LET is_linkable_var =
is_extern_var() AND is_extern_var() AND
declaration_has_name(REGEXP("Linkable_.*")) AND declaration_has_name(REGEXP("Linkable_.*")) AND
has_type("char"); has_type("char");
@ -924,12 +924,12 @@ DEFINE-CHECKER CAT_DECL_MACRO = {
HOLDS-NEXT WITH-TRANSITION Sibling HOLDS-NEXT WITH-TRANSITION Sibling
(is_node("VarDecl") AND is_linkable_var()); (is_node("VarDecl") AND is_linkable_var());
SET report_when = SET report_when =
WHEN WHEN
NOT ( NOT (
is_node("ObjCCategoryDecl") is_node("ObjCCategoryDecl")
AND-WITH-WITNESSES var_decls() : decl_name_is_contained_in_name_of_decl() AND-WITH-WITNESSES var_decls() : decl_name_is_contained_in_name_of_decl()
) )
HOLDS-IN-NODE ObjCCategoryDecl; HOLDS-IN-NODE ObjCCategoryDecl;
SET message = "A category is defined without the corresponding macro"; SET message = "A category is defined without the corresponding macro";
@ -937,7 +937,7 @@ DEFINE-CHECKER CAT_DECL_MACRO = {
DEFINE-CHECKER CAT_IMPL_MACRO = { DEFINE-CHECKER CAT_IMPL_MACRO = {
LET is_linkable_var = LET is_linkable_var =
has_visibility_attribute("Default") AND has_visibility_attribute("Default") AND
declaration_has_name(REGEXP("Linkable_.*")) AND declaration_has_name(REGEXP("Linkable_.*")) AND
has_type("char"); has_type("char");
@ -946,12 +946,12 @@ DEFINE-CHECKER CAT_IMPL_MACRO = {
HOLDS-NEXT WITH-TRANSITION Sibling HOLDS-NEXT WITH-TRANSITION Sibling
(is_node("VarDecl") AND is_linkable_var()); (is_node("VarDecl") AND is_linkable_var());
SET report_when = SET report_when =
WHEN WHEN
NOT ( NOT (
is_node("ObjCCategoryImplDecl") is_node("ObjCCategoryImplDecl")
AND-WITH-WITNESSES var_decls() : decl_name_is_contained_in_name_of_decl() AND-WITH-WITNESSES var_decls() : decl_name_is_contained_in_name_of_decl()
) HOLDS-IN-NODE ObjCCategoryImplDecl; ) HOLDS-IN-NODE ObjCCategoryImplDecl;
SET message = "A category is implemented without the corresponding macro"; SET message = "A category is implemented without the corresponding macro";
}; };

@ -1,9 +1,9 @@
codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 19, ALL_PATH_NO_FILTER_EXAMPLE, no_bucket, WARNING, [] codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 22, ALL_PATH_NO_FILTER_EXAMPLE, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 19, BLACKLIST_PATH_EXAMPLE, no_bucket, WARNING, [] codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 22, BLACKLIST_PATH_EXAMPLE, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 19, FILTER_BY_ALL_PATH_EXAMPLE, no_bucket, WARNING, [] codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 22, FILTER_BY_ALL_PATH_EXAMPLE, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 19, WHITE_BLACKLIST_PATH_EXAMPLE, no_bucket, WARNING, [] codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 22, WHITE_BLACKLIST_PATH_EXAMPLE, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 20, CALLS_TO_FUNCTIONS_WITH_CREATE_FUNCTION_PARAMETERS, no_bucket, WARNING, [] codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 23, CALLS_TO_FUNCTIONS_WITH_CREATE_FUNCTION_PARAMETERS, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 21, CALLS_TO_FUNCTIONS_WITH_CREATE_FUNCTION_PARAMETERS, no_bucket, WARNING, [] codetoanalyze/objc/linters-for-test-only/CFStringExample.m, main, 24, CALLS_TO_FUNCTIONS_WITH_CREATE_FUNCTION_PARAMETERS, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/CallingAMethodWithSelf.m, CallingAMethodWithSelf::methodThatShallBeOkaySuper, 35, TEST_IS_RECEIVER_SUPER, no_bucket, WARNING, [] codetoanalyze/objc/linters-for-test-only/CallingAMethodWithSelf.m, CallingAMethodWithSelf::methodThatShallBeOkaySuper, 35, TEST_IS_RECEIVER_SUPER, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/CallingAMethodWithSelf.m, CallingAMethodWithSelf::methodThatShallComplain, 38, TEST_IS_METHOD_EXPOSED, no_bucket, WARNING, [] codetoanalyze/objc/linters-for-test-only/CallingAMethodWithSelf.m, CallingAMethodWithSelf::methodThatShallComplain, 38, TEST_IS_METHOD_EXPOSED, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/CallingAMethodWithSelf.m, CallingAMethodWithSelf::methodThatShallComplain, 39, TEST_IF_VIEW_METHOD_IS_NOT_CALLED_WITH_SUPER, no_bucket, WARNING, [] codetoanalyze/objc/linters-for-test-only/CallingAMethodWithSelf.m, CallingAMethodWithSelf::methodThatShallComplain, 39, TEST_IF_VIEW_METHOD_IS_NOT_CALLED_WITH_SUPER, no_bucket, WARNING, []

Loading…
Cancel
Save