Check early whether the given decl has to be checked with linters or not

Reviewed By: dulmarod

Differential Revision: D3728836

fbshipit-source-id: a3fa865
master
Martino Luca 9 years ago committed by Facebook Github Bot 6
parent e1f19192c0
commit 7de52e7649

@ -76,7 +76,11 @@ let do_frontend_checks cfg cg source_file ast =
match ast with
| Clang_ast_t.TranslationUnitDecl(_, decl_list, _, _) ->
let context = context_with_ck_set CLintersContext.empty decl_list in
IList.iter (do_frontend_checks_decl context cfg cg) decl_list;
let is_decl_allowed decl =
let decl_info = Clang_ast_proj.get_decl_tuple decl in
CLocation.should_do_frontend_check decl_info.Clang_ast_t.di_source_range in
let allowed_decls = IList.filter is_decl_allowed decl_list in
IList.iter (do_frontend_checks_decl context cfg cg) allowed_decls;
(* TODO (t12740727): Remove condition once the transition to linters mode is finished *)
if Config.analyzer = Some Config.Linters then store_issues source_file
| _ -> assert false (* NOTE: Assumes that an AST alsways starts with a TranslationUnitDecl *)

@ -161,27 +161,24 @@ let run_frontend_checkers_on_stmt context cfg cg instr =
let run_frontend_checkers_on_decl context cfg cg dec =
let open Clang_ast_t in
let decl_info = Clang_ast_proj.get_decl_tuple dec in
if CLocation.should_do_frontend_check decl_info.Clang_ast_t.di_source_range then
match dec with
| ObjCImplementationDecl (decl_info, _, decl_list, _, _)
| ObjCProtocolDecl (decl_info, _, decl_list, _, _) ->
let idi = match dec with
| ObjCImplementationDecl (_, _, _, _, impl_decl_info) -> Some impl_decl_info
| _ -> None in
let call_ns_checker = checkers_for_ns decl_info idi decl_list in
let key = Ast_utils.generate_key_decl dec in
invoke_set_of_checkers call_ns_checker context cfg cg key ns_notification_checker_list;
context
| VarDecl _ ->
let call_var_checker = checker_for_var dec in
let key = Ast_utils.generate_key_decl dec in
invoke_set_of_checkers call_var_checker context cfg cg key var_checker_list;
context
| ObjCPropertyDecl (decl_info, pname_info, pdi) ->
let call_property_checker = checkers_for_property decl_info pname_info pdi in
let key = Ast_utils.generate_key_decl dec in
invoke_set_of_checkers call_property_checker context cfg cg key property_checkers_list;
context
| _ -> context
else context
match dec with
| ObjCImplementationDecl (decl_info, _, decl_list, _, _)
| ObjCProtocolDecl (decl_info, _, decl_list, _, _) ->
let idi = match dec with
| ObjCImplementationDecl (_, _, _, _, impl_decl_info) -> Some impl_decl_info
| _ -> None in
let call_ns_checker = checkers_for_ns decl_info idi decl_list in
let key = Ast_utils.generate_key_decl dec in
invoke_set_of_checkers call_ns_checker context cfg cg key ns_notification_checker_list;
context
| VarDecl _ ->
let call_var_checker = checker_for_var dec in
let key = Ast_utils.generate_key_decl dec in
invoke_set_of_checkers call_var_checker context cfg cg key var_checker_list;
context
| ObjCPropertyDecl (decl_info, pname_info, pdi) ->
let call_property_checker = checkers_for_property decl_info pname_info pdi in
let key = Ast_utils.generate_key_decl dec in
invoke_set_of_checkers call_property_checker context cfg cg key property_checkers_list;
context
| _ -> context

Loading…
Cancel
Save