From 780006097a99bfabb40becefbea37e970c662de8 Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Wed, 2 May 2018 09:11:13 -0700 Subject: [PATCH] [clang frontend] Do not crash when finding unexpected declarations when collecting local variables Reviewed By: sblackshear, mbouaziz Differential Revision: D7845304 fbshipit-source-id: f692820 --- infer/src/clang/cTrans.ml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index a0d1bf06c..143e2a614 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -2276,17 +2276,10 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s ; exps= [] ; initd_exps= res_trans_tmp.initd_exps @ res_trans_vd.initd_exps } , Some leaf_nodes ) - | CXXRecordDecl _ :: var_decls' - (*C++/C record decl treated in the same way *) - | RecordDecl _ :: var_decls' -> - (* Record declaration is done in the beginning when procdesc is defined.*) + | _ :: var_decls' -> + (* Here we can get also record declarations or typedef declarations, which are dealt with somewhere else. + We just handle the variables here. *) collect_all_decl_inner trans_state var_decls' - | decl :: _ -> - CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range - "unexpected decl type %s in collect_all_decl: %a" - (Clang_ast_proj.get_decl_kind_string decl) - (Pp.to_string ~f:Clang_ast_j.string_of_decl) - decl in let res_trans, leaf_nodes_opt = collect_all_decl_inner trans_state var_decls in match leaf_nodes_opt with Some leaf_nodes -> {res_trans with leaf_nodes} | None -> res_trans