[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;
let context' =
(match decl with (match decl with
| FunctionDecl(_, _, _, fdi) | FunctionDecl(_, _, _, fdi)
| CXXMethodDecl (_, _, _, fdi, _) | CXXMethodDecl (_, _, _, fdi, _)
| CXXConstructorDecl (_, _, _, fdi, _) | CXXConstructorDecl (_, _, _, fdi, _)
| CXXConversionDecl (_, _, _, fdi, _) | CXXConversionDecl (_, _, _, fdi, _)
| CXXDestructorDecl (_, _, _, fdi, _) -> | CXXDestructorDecl (_, _, _, fdi, _) ->
let context' = {context with CLintersContext.current_method = Some decl } in
(match fdi.Clang_ast_t.fdi_body with (match fdi.Clang_ast_t.fdi_body with
| Some stmt -> | Some stmt ->
let context = {context with CLintersContext.current_method = Some decl } in do_frontend_checks_stmt context' stmt
do_frontend_checks_stmt context stmt | None -> ());
| None -> ()) context'
| ObjCMethodDecl (_, _, mdi) -> | ObjCMethodDecl (_, _, mdi) ->
let context' = {context with CLintersContext.current_method = Some decl } in
(match mdi.Clang_ast_t.omdi_body with (match mdi.Clang_ast_t.omdi_body with
| Some stmt -> | Some stmt ->
let context = {context with CLintersContext.current_method = Some decl } in do_frontend_checks_stmt context' stmt
do_frontend_checks_stmt context stmt | None -> ());
| None -> ()) context'
| BlockDecl (_, block_decl_info) -> | BlockDecl (_, block_decl_info) ->
let context' = {context with CLintersContext.current_method = Some decl } in
(match block_decl_info.Clang_ast_t.bdi_body with (match block_decl_info.Clang_ast_t.bdi_body with
| Some stmt -> | Some stmt ->
let context = {context with CLintersContext.current_method = Some decl } in do_frontend_checks_stmt context' stmt
do_frontend_checks_stmt context stmt | None -> ());
| None -> ()) context'
| _ -> ()); | _ -> context) in
let context' = CFrontend_errors.run_frontend_checkers_on_decl context decl 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