From a1d7df6c07c67bf4375a2fe4a2248d2687a21bdd Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Thu, 29 Sep 2016 04:15:14 -0700 Subject: [PATCH] [linters] Log assert failures in the linters framework Reviewed By: ddino Differential Revision: D3937986 fbshipit-source-id: 0926d72 --- infer/src/clang/cFrontend_checkers_main.ml | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/infer/src/clang/cFrontend_checkers_main.ml b/infer/src/clang/cFrontend_checkers_main.ml index 453768466..cde5368b8 100644 --- a/infer/src/clang/cFrontend_checkers_main.ml +++ b/infer/src/clang/cFrontend_checkers_main.ml @@ -80,16 +80,21 @@ let store_issues source_file = LintIssues.store_issues lint_issues_file !LintIssues.errLogMap let do_frontend_checks source_file ast = - Logging.out "Start linting file %s\n" (DB.source_file_to_string source_file); - match ast with - | Clang_ast_t.TranslationUnitDecl(_, decl_list, _, _) -> - let context = context_with_ck_set CLintersContext.empty decl_list in - 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) allowed_decls; - if (LintIssues.exists_issues ()) then - store_issues source_file; - Logging.out "End linting file %s\n" (DB.source_file_to_string source_file) - | _ -> assert false (* NOTE: Assumes that an AST alsways starts with a TranslationUnitDecl *) + try + Logging.out "Start linting file %s\n" (DB.source_file_to_string source_file); + match ast with + | Clang_ast_t.TranslationUnitDecl(_, decl_list, _, _) -> + let context = context_with_ck_set CLintersContext.empty decl_list in + 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) allowed_decls; + if (LintIssues.exists_issues ()) then + store_issues source_file; + Logging.out "End linting file %s\n" (DB.source_file_to_string source_file) + | _ -> assert false (* NOTE: Assumes that an AST alsways starts with a TranslationUnitDecl *) + with + | Assert_failure (file, line, column) -> + Logging.out "Fatal error: exception Assert_failure(%s, %d, %d)\n%!" file line column; + exit 1