[AL] Make the transition Parameters work with function calls

Summary: The transition HOLDS-NEXT WITH-TRANSITION Parameters  was only implemented for ObjC methods, now it also works on function calls.

Reviewed By: jvillard

Differential Revision: D18572760

fbshipit-source-id: 06e615cbe
master
Dulma Churchill 5 years ago committed by Facebook Github Bot
parent d5b574dd80
commit e411db6f82

@ -806,7 +806,9 @@ let transition_via_parameters an =
match an with match an with
| Decl (ObjCMethodDecl (_, _, omdi)) -> | Decl (ObjCMethodDecl (_, _, omdi)) ->
List.map ~f:(fun d -> Decl d) omdi.omdi_parameters List.map ~f:(fun d -> Decl d) omdi.omdi_parameters
| Stmt (ObjCMessageExpr (_, stmt_list, _, _)) -> | Stmt (ObjCMessageExpr (_, stmt_list, _, _))
| Stmt (CallExpr (_, _ :: stmt_list, _))
| Stmt (CXXMemberCallExpr (_, stmt_list, _)) ->
List.map ~f:(fun stmt -> Stmt stmt) stmt_list List.map ~f:(fun stmt -> Stmt stmt) stmt_list
| _ -> | _ ->
[] []

@ -0,0 +1,24 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Foundation/Foundation.h>
static CFStringRef CreateFoo() {
return CFStringCreateWithCString(NULL, "Hello", kCFStringEncodingUTF8);
}
static void doSomething(CFStringRef s) { CFShow(s); }
static void doSomethingElse(int x, CFStringRef s) { CFShow(s); }
static void Foo() {}
int main() {
doSomething(CreateFoo());
doSomethingElse(0, CreateFoo());
Foo();
return 0;
}

@ -888,3 +888,12 @@ DEFINE-CHECKER IVAR_CAPTURED_IN_OBJC_BLOCK = {
SET severity = "ERROR"; SET severity = "ERROR";
SET mode = "ON"; SET mode = "ON";
}; };
DEFINE-CHECKER CALLS_TO_FUNCTIONS_WITH_CREATE_FUNCTION_PARAMETERS = {
LET is_create_method_parameter = HOLDS-NEXT WITH-TRANSITION Parameters
(call_function(REGEXP(".*Create.*")) AND has_type("REGEXP('C.*Ref')"));
SET report_when =
WHEN
is_create_method_parameter
HOLDS-IN-NODE CallExpr;
};

@ -1,3 +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, 19, 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, 19, 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, 21, 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