[linters] Pass the current method in the context to the checks about the methods or functions declarations

Reviewed By: ddino

Differential Revision: D3937070

fbshipit-source-id: da7b4a6
master
Dulma Churchill 8 years ago committed by Facebook Github Bot
parent e3b4820e54
commit a44109b2b2

@ -28,33 +28,39 @@ and do_frontend_checks_decl context decl =
let open Clang_ast_t in let open Clang_ast_t in
let info = Clang_ast_proj.get_decl_tuple decl in let info = Clang_ast_proj.get_decl_tuple decl in
CLocation.update_curr_file info; CLocation.update_curr_file info;
(match decl with let context' =
| FunctionDecl(_, _, _, fdi) (match decl with
| CXXMethodDecl (_, _, _, fdi, _) | FunctionDecl(_, _, _, fdi)
| CXXConstructorDecl (_, _, _, fdi, _) | CXXMethodDecl (_, _, _, fdi, _)
| CXXConversionDecl (_, _, _, fdi, _) | CXXConstructorDecl (_, _, _, fdi, _)
| CXXDestructorDecl (_, _, _, fdi, _) -> | CXXConversionDecl (_, _, _, fdi, _)
(match fdi.Clang_ast_t.fdi_body with | CXXDestructorDecl (_, _, _, fdi, _) ->
| Some stmt -> let context' = {context with CLintersContext.current_method = Some decl } in
let context = {context with CLintersContext.current_method = Some decl } in (match fdi.Clang_ast_t.fdi_body with
do_frontend_checks_stmt context stmt | Some stmt ->
| None -> ()) do_frontend_checks_stmt context' stmt
| ObjCMethodDecl (_, _, mdi) -> | None -> ());
(match mdi.Clang_ast_t.omdi_body with context'
| Some stmt -> | ObjCMethodDecl (_, _, mdi) ->
let context = {context with CLintersContext.current_method = Some decl } in let context' = {context with CLintersContext.current_method = Some decl } in
do_frontend_checks_stmt context stmt (match mdi.Clang_ast_t.omdi_body with
| None -> ()) | Some stmt ->
| BlockDecl (_, block_decl_info) -> do_frontend_checks_stmt context' stmt
(match block_decl_info.Clang_ast_t.bdi_body with | None -> ());
| Some stmt -> context'
let context = {context with CLintersContext.current_method = Some decl } in | BlockDecl (_, block_decl_info) ->
do_frontend_checks_stmt context stmt let context' = {context with CLintersContext.current_method = Some decl } in
| None -> ()) (match block_decl_info.Clang_ast_t.bdi_body with
| _ -> ()); | Some stmt ->
let context' = CFrontend_errors.run_frontend_checkers_on_decl context decl in do_frontend_checks_stmt context' stmt
| None -> ());
context'
| _ -> context) in
let context'' = CFrontend_errors.run_frontend_checkers_on_decl context' decl in
let context_with_orig_current_method =
{context'' with CLintersContext.current_method = context.CLintersContext.current_method } in
match Clang_ast_proj.get_decl_context_tuple decl with match Clang_ast_proj.get_decl_context_tuple decl with
| Some (decls, _) -> IList.iter (do_frontend_checks_decl context') decls | Some (decls, _) -> IList.iter (do_frontend_checks_decl context_with_orig_current_method) decls
| None -> () | None -> ()
let context_with_ck_set context decl_list = let context_with_ck_set context decl_list =

Loading…
Cancel
Save