From d2a4028881f39b73940da7bb3e17a0313e518c41 Mon Sep 17 00:00:00 2001 From: Ryan Rhee Date: Tue, 2 Aug 2016 12:07:16 -0700 Subject: [PATCH] Call decl checkers on DeclStmt statements Reviewed By: jvillard Differential Revision: D3649322 fbshipit-source-id: 60b1b92 --- infer/src/clang/cFrontend_checkers_main.ml | 11 ++++++++--- .../tests/endtoend/objcpp/linters/GlobalVarTest.java | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/infer/src/clang/cFrontend_checkers_main.ml b/infer/src/clang/cFrontend_checkers_main.ml index 933d02b6b..271fe7623 100644 --- a/infer/src/clang/cFrontend_checkers_main.ml +++ b/infer/src/clang/cFrontend_checkers_main.ml @@ -10,9 +10,14 @@ let rec do_frontend_checks_stmt (context:CLintersContext.context) cfg cg method_decl stmt = let context' = CFrontend_errors.run_frontend_checkers_on_stmt context cfg cg method_decl stmt in let stmts = CFrontend_utils.Ast_utils.get_stmts_from_stmt stmt in - IList.iter (do_frontend_checks_stmt context' cfg cg method_decl) stmts - -let rec do_frontend_checks_decl context cfg cg decl = + let do_all_checks_on_stmts stmt = + (match stmt with + | Clang_ast_t.DeclStmt (_, _, decl_list) -> + IList.iter (do_frontend_checks_decl context' cfg cg) decl_list + | _ -> ()); + do_frontend_checks_stmt context' cfg cg method_decl stmt in + IList.iter (do_all_checks_on_stmts) stmts +and do_frontend_checks_decl context cfg cg decl = let open Clang_ast_t in let info = Clang_ast_proj.get_decl_tuple decl in CLocation.update_curr_file info; diff --git a/infer/tests/endtoend/objcpp/linters/GlobalVarTest.java b/infer/tests/endtoend/objcpp/linters/GlobalVarTest.java index 59b125143..c8e4d0988 100644 --- a/infer/tests/endtoend/objcpp/linters/GlobalVarTest.java +++ b/infer/tests/endtoend/objcpp/linters/GlobalVarTest.java @@ -53,7 +53,7 @@ public class GlobalVarTest { assertThat( "Results should contain " + GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL, inferResults, - containsOnlyLines(new int[]{30, 32, 34})); + containsOnlyLines(new int[]{30, 32, 34, 52, 54, 56})); } }