[clang] move error handling from cFrontend_config to a new cFrontend_errors module

Summary:
This isn't really a "config" part of the frontend and this change is
needed later to catch these errors more robustly.

Reviewed By: ngorogiannis

Differential Revision: D16963177

fbshipit-source-id: 293b23acf
master
Jules Villard 6 years ago committed by Facebook Github Bot
parent fadd8cb541
commit b59ff499c7

@ -499,7 +499,7 @@ let fill_issue_desc_info_and_log context ~witness ~current_node (issue_desc : CI
let suggestion = Option.map ~f:process_message issue_desc.suggestion in let suggestion = Option.map ~f:process_message issue_desc.suggestion in
let issue_desc' = {issue_desc with description; loc; suggestion} in let issue_desc' = {issue_desc with description; loc; suggestion} in
try log_frontend_issue context.CLintersContext.current_method witness issue_desc' try log_frontend_issue context.CLintersContext.current_method witness issue_desc'
with CFrontend_config.IncorrectAssumption e -> with CFrontend_errors.IncorrectAssumption e ->
let trans_unit_ctx = context.CLintersContext.translation_unit_context in let trans_unit_ctx = context.CLintersContext.translation_unit_context in
ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position
e.source_range e.ast_node e.source_range e.ast_node

@ -162,7 +162,7 @@ let mutable_local_vars_advice context an =
| _ -> | _ ->
None None
else None else None
with CFrontend_config.IncorrectAssumption e -> with CFrontend_errors.IncorrectAssumption e ->
let trans_unit_ctx = context.CLintersContext.translation_unit_context in let trans_unit_ctx = context.CLintersContext.translation_unit_context in
ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position
e.source_range e.ast_node ; e.source_range e.ast_node ;

@ -1386,7 +1386,7 @@ and eval_formula f an lcxt : Ctl_parser_types.ast_node option =
None None
| Atomic (name, params) -> ( | Atomic (name, params) -> (
try if eval_Atomic name params an lcxt then Some an else None try if eval_Atomic name params an lcxt then Some an else None
with CFrontend_config.IncorrectAssumption e -> with CFrontend_errors.IncorrectAssumption e ->
let trans_unit_ctx = lcxt.CLintersContext.translation_unit_context in let trans_unit_ctx = lcxt.CLintersContext.translation_unit_context in
ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position
e.source_range e.ast_node ; e.source_range e.ast_node ;

@ -25,7 +25,7 @@ let get_method_kind meth_decl =
| BlockDecl _ -> | BlockDecl _ ->
ClangMethodKind.BLOCK ClangMethodKind.BLOCK
| _ -> | _ ->
raise CFrontend_config.Invalid_declaration raise CFrontend_errors.Invalid_declaration
let rec is_inside_objc_class_method meth_decl = let rec is_inside_objc_class_method meth_decl =
@ -55,7 +55,7 @@ let get_return_type method_decl =
| ObjCMethodDecl (_, _, omdi) -> | ObjCMethodDecl (_, _, omdi) ->
omdi.omdi_result_type omdi.omdi_result_type
| _ -> | _ ->
raise CFrontend_config.Invalid_declaration raise CFrontend_errors.Invalid_declaration
let get_param_decls method_decl = let get_param_decls method_decl =
@ -72,7 +72,7 @@ let get_param_decls method_decl =
| BlockDecl (_, block_decl_info) -> | BlockDecl (_, block_decl_info) ->
block_decl_info.bdi_parameters block_decl_info.bdi_parameters
| _ -> | _ ->
raise CFrontend_config.Invalid_declaration raise CFrontend_errors.Invalid_declaration
let get_method_body method_decl = let get_method_body method_decl =
@ -89,7 +89,7 @@ let get_method_body method_decl =
| BlockDecl (_, block_decl_info) -> | BlockDecl (_, block_decl_info) ->
block_decl_info.bdi_body block_decl_info.bdi_body
| _ -> | _ ->
raise CFrontend_config.Invalid_declaration raise CFrontend_errors.Invalid_declaration
let is_cpp_virtual method_decl = let is_cpp_virtual method_decl =
@ -161,7 +161,7 @@ let is_variadic method_decl =
| BlockDecl (_, block_decl_info) -> | BlockDecl (_, block_decl_info) ->
block_decl_info.bdi_is_variadic block_decl_info.bdi_is_variadic
| _ -> | _ ->
raise CFrontend_config.Invalid_declaration raise CFrontend_errors.Invalid_declaration
let get_block_captured_variables method_decl = let get_block_captured_variables method_decl =

@ -50,7 +50,7 @@ module BuildMethodSignature = struct
| _ -> | _ ->
None ) None )
| _ -> | _ ->
raise CFrontend_config.Invalid_declaration raise CFrontend_errors.Invalid_declaration
let should_add_return_param return_type ~is_objc_method = let should_add_return_param return_type ~is_objc_method =
@ -98,7 +98,7 @@ module BuildMethodSignature = struct
let annot = CAst_utils.sil_annot_of_type qt in let annot = CAst_utils.sil_annot_of_type qt in
CMethodSignature.mk_param_type name typ ~is_pointer_to_const ~annot CMethodSignature.mk_param_type name typ ~is_pointer_to_const ~annot
| _ -> | _ ->
raise CFrontend_config.Invalid_declaration raise CFrontend_errors.Invalid_declaration
in in
let params = List.map ~f:par_to_ms_par (CMethodProperties.get_param_decls method_decl) in let params = List.map ~f:par_to_ms_par (CMethodProperties.get_param_decls method_decl) in
let return_param = let return_param =
@ -614,7 +614,7 @@ and get_class_typename ?tenv method_decl_info =
| Some class_decl -> | Some class_decl ->
get_record_typename ?tenv class_decl get_record_typename ?tenv class_decl
| None -> | None ->
CFrontend_config.incorrect_assumption __POS__ method_decl_info.Clang_ast_t.di_source_range CFrontend_errors.incorrect_assumption __POS__ method_decl_info.Clang_ast_t.di_source_range
"Expecting class declaration when getting the class typename" "Expecting class declaration when getting the class typename"

@ -165,7 +165,7 @@ let make_next_object_exp stmt_info item items =
| [stmt] -> | [stmt] ->
get_decl_ref stmt get_decl_ref stmt
| _ -> | _ ->
CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range
"unexpected item %a" "unexpected item %a"
(Pp.to_string ~f:Clang_ast_j.string_of_stmt) (Pp.to_string ~f:Clang_ast_j.string_of_stmt)
item ) item )

@ -59,7 +59,7 @@ let binary_operation_instruction source_range boi ((e1, t1) as e1_with_typ) typ
but the translation of the argument expressions does not compute such but the translation of the argument expressions does not compute such
offsets and instead passes the member pointer at type 'void'. *) offsets and instead passes the member pointer at type 'void'. *)
| `PtrMemD | `PtrMemI -> | `PtrMemD | `PtrMemI ->
CFrontend_config.unimplemented __POS__ source_range CFrontend_errors.unimplemented __POS__ source_range
"Pointer-to-member constructs are unsupported. Got '%a'." "Pointer-to-member constructs are unsupported. Got '%a'."
(Pp.to_string ~f:Clang_ast_j.string_of_binary_operator_info) (Pp.to_string ~f:Clang_ast_j.string_of_binary_operator_info)
boi boi
@ -106,7 +106,7 @@ let binary_operation_instruction source_range boi ((e1, t1) as e1_with_typ) typ
| `Assign -> | `Assign ->
(e1, [Sil.Store (e1, typ, e2, loc)]) (e1, [Sil.Store (e1, typ, e2, loc)])
| `Cmp -> | `Cmp ->
CFrontend_config.unimplemented __POS__ source_range "C++20 spaceship operator <=>" CFrontend_errors.unimplemented __POS__ source_range "C++20 spaceship operator <=>"
(* C++20 spaceship operator <=>, TODO *) (* C++20 spaceship operator <=>, TODO *)
| `Comma -> | `Comma ->
(e2, []) (* C99 6.5.17-2 *) (e2, []) (* C99 6.5.17-2 *)

@ -110,7 +110,7 @@ let get_decl_opt decl_ptr_opt =
let get_stmt stmt_ptr source_range = let get_stmt stmt_ptr source_range =
let stmt = Int.Table.find ClangPointers.pointer_stmt_table stmt_ptr in let stmt = Int.Table.find ClangPointers.pointer_stmt_table stmt_ptr in
if Option.is_none stmt then if Option.is_none stmt then
CFrontend_config.incorrect_assumption __POS__ source_range "stmt with pointer %d not found@\n" CFrontend_errors.incorrect_assumption __POS__ source_range "stmt with pointer %d not found@\n"
stmt_ptr ; stmt_ptr ;
stmt stmt

@ -73,7 +73,7 @@ let get_curr_class_decl_ptr stmt_info curr_class =
| ContextClsDeclPtr ptr -> | ContextClsDeclPtr ptr ->
ptr ptr
| _ -> | _ ->
CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range
"current class is not ContextClsDeclPtr" "current class is not ContextClsDeclPtr"

@ -6,7 +6,6 @@
*) *)
open! IStd open! IStd
module F = Format
(** Module that contains constants and global state used in the frontend *) (** Module that contains constants and global state used in the frontend *)
@ -18,29 +17,9 @@ let string_of_clang_lang (lang : clang_lang) : string =
let equal_clang_lang = [%compare.equal: clang_lang] let equal_clang_lang = [%compare.equal: clang_lang]
type exception_details =
{ msg: string
; position: Logging.ocaml_pos
; source_range: Clang_ast_t.source_range
; ast_node: string option }
exception Unimplemented of exception_details
let unimplemented position source_range ?ast_node fmt =
F.kasprintf (fun msg -> raise (Unimplemented {msg; position; source_range; ast_node})) fmt
exception IncorrectAssumption of exception_details
let incorrect_assumption position source_range ?ast_node fmt =
F.kasprintf (fun msg -> raise (IncorrectAssumption {msg; position; source_range; ast_node})) fmt
type translation_unit_context = type translation_unit_context =
{lang: clang_lang; source_file: SourceFile.t; integer_type_widths: Typ.IntegerWidths.t} {lang: clang_lang; source_file: SourceFile.t; integer_type_widths: Typ.IntegerWidths.t}
exception Invalid_declaration
(** Constants *) (** Constants *)
let alloc = "alloc" let alloc = "alloc"

@ -15,39 +15,9 @@ val string_of_clang_lang : clang_lang -> string
val equal_clang_lang : clang_lang -> clang_lang -> bool val equal_clang_lang : clang_lang -> clang_lang -> bool
type exception_details =
{ msg: string
; position: Logging.ocaml_pos
; source_range: Clang_ast_t.source_range
; ast_node: string option }
exception Unimplemented of exception_details
val unimplemented :
Logging.ocaml_pos
-> Clang_ast_t.source_range
-> ?ast_node:string
-> ('a, Format.formatter, unit, _) format4
-> 'a
(** Raise Unimplemented. This is caught at the level of translating a method and makes the frontend
give up on that method. *)
exception IncorrectAssumption of exception_details
val incorrect_assumption :
Logging.ocaml_pos
-> Clang_ast_t.source_range
-> ?ast_node:string
-> ('a, Format.formatter, unit, _) format4
-> 'a
(** Used to mark places in the frontend that incorrectly assume something to be
impossible. TODO(t21762295) get rid of all instances of this. *)
type translation_unit_context = type translation_unit_context =
{lang: clang_lang; source_file: SourceFile.t; integer_type_widths: Typ.IntegerWidths.t} {lang: clang_lang; source_file: SourceFile.t; integer_type_widths: Typ.IntegerWidths.t}
exception Invalid_declaration
(** Constants *) (** Constants *)
val alloc : string val alloc : string

@ -22,11 +22,11 @@ let protect ~f ~recover ~pp_context (trans_unit_ctx : CFrontend_config.translati
(* Always keep going in case of known limitations of the frontend, crash otherwise (by not (* Always keep going in case of known limitations of the frontend, crash otherwise (by not
catching the exception) unless `--keep-going` was passed. Print errors we should fix catching the exception) unless `--keep-going` was passed. Print errors we should fix
(t21762295) to the console. *) (t21762295) to the console. *)
| CFrontend_config.Unimplemented e -> | CFrontend_errors.Unimplemented e ->
ClangLogging.log_caught_exception trans_unit_ctx "Unimplemented" e.position e.source_range ClangLogging.log_caught_exception trans_unit_ctx "Unimplemented" e.position e.source_range
e.ast_node ; e.ast_node ;
log_and_recover ~print:false "Unimplemented feature:@\n %s@\n" e.msg log_and_recover ~print:false "Unimplemented feature:@\n %s@\n" e.msg
| CFrontend_config.IncorrectAssumption e -> | CFrontend_errors.IncorrectAssumption e ->
(* FIXME(t21762295): we do not expect this to happen but it does *) (* FIXME(t21762295): we do not expect this to happen but it does *)
ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position
e.source_range e.ast_node ; e.source_range e.ast_node ;
@ -122,7 +122,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron
return_param_typ_opt outer_context_opt extra_instrs return_param_typ_opt outer_context_opt extra_instrs
| None -> | None ->
() ()
with CFrontend_config.IncorrectAssumption e -> with CFrontend_errors.IncorrectAssumption e ->
ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position
e.source_range e.ast_node e.source_range e.ast_node
@ -170,7 +170,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron
ignore ignore
(CMethod_trans.create_local_procdesc ~set_objc_accessor_attr trans_unit_ctx cfg tenv (CMethod_trans.create_local_procdesc ~set_objc_accessor_attr trans_unit_ctx cfg tenv
ms [] []) ms [] [])
with CFrontend_config.IncorrectAssumption e -> with CFrontend_errors.IncorrectAssumption e ->
ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position
e.source_range e.ast_node e.source_range e.ast_node

@ -0,0 +1,28 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
module F = Format
type exception_details =
{ msg: string
; position: Logging.ocaml_pos
; source_range: Clang_ast_t.source_range
; ast_node: string option }
exception Unimplemented of exception_details
exception IncorrectAssumption of exception_details
exception Invalid_declaration
let unimplemented position source_range ?ast_node fmt =
F.kasprintf (fun msg -> raise (Unimplemented {msg; position; source_range; ast_node})) fmt
let incorrect_assumption position source_range ?ast_node fmt =
F.kasprintf (fun msg -> raise (IncorrectAssumption {msg; position; source_range; ast_node})) fmt

@ -0,0 +1,38 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
type exception_details =
{ msg: string
; position: Logging.ocaml_pos
; source_range: Clang_ast_t.source_range
; ast_node: string option }
exception Unimplemented of exception_details
exception IncorrectAssumption of exception_details
exception Invalid_declaration
val unimplemented :
Logging.ocaml_pos
-> Clang_ast_t.source_range
-> ?ast_node:string
-> ('a, Format.formatter, unit, _) format4
-> 'a
(** Raise Unimplemented. This is caught at the level of translating a method and makes the frontend
give up on that method. *)
val incorrect_assumption :
Logging.ocaml_pos
-> Clang_ast_t.source_range
-> ?ast_node:string
-> ('a, Format.formatter, unit, _) format4
-> 'a
(** Used to mark places in the frontend that incorrectly assume something to be
impossible. TODO(t21762295) get rid of all instances of this. *)

@ -86,7 +86,7 @@ let get_var_name_mangled decl_info name_info var_decl_info =
| "", Some index -> | "", Some index ->
"__param_" ^ string_of_int index "__param_" ^ string_of_int index
| "", None -> | "", None ->
CFrontend_config.incorrect_assumption __POS__ decl_info.Clang_ast_t.di_source_range CFrontend_errors.incorrect_assumption __POS__ decl_info.Clang_ast_t.di_source_range
"Got both empty clang_name and None for param_idx in get_var_name_mangled (%a) (%a)" "Got both empty clang_name and None for param_idx in get_var_name_mangled (%a) (%a)"
(Pp.to_string ~f:Clang_ast_j.string_of_named_decl_info) (Pp.to_string ~f:Clang_ast_j.string_of_named_decl_info)
name_info name_info

@ -29,7 +29,7 @@ let method_signature_of_pointer tenv pointer =
Some ms Some ms
| None -> | None ->
None None
with CFrontend_config.Invalid_declaration -> None with CFrontend_errors.Invalid_declaration -> None
let get_method_name_from_clang tenv ms_opt = let get_method_name_from_clang tenv ms_opt =

@ -165,7 +165,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
ei ei
| None -> | None ->
let stmt_info, _ = Clang_ast_proj.get_stmt_tuple stmt in let stmt_info, _ = Clang_ast_proj.get_stmt_tuple stmt in
CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range
"Clang_ast_proj.get_expr_tuple stmt returns None, stmt is %a" "Clang_ast_proj.get_expr_tuple stmt returns None, stmt is %a"
(Pp.to_string ~f:Clang_ast_j.string_of_stmt) (Pp.to_string ~f:Clang_ast_j.string_of_stmt)
stmt stmt
@ -425,13 +425,13 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let instrs = [Sil.Store (exp, typ, zero_exp, sil_loc)] in let instrs = [Sil.Store (exp, typ, zero_exp, sil_loc)] in
mk_trans_result (exp, typ) {empty_control with instrs} mk_trans_result (exp, typ) {empty_control with instrs}
| Tfun _ | Tvoid | Tarray _ | TVar _ -> | Tfun _ | Tvoid | Tarray _ | TVar _ ->
CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range
"fill_typ_with_zero on type %a" (Typ.pp Pp.text) typ "fill_typ_with_zero on type %a" (Typ.pp Pp.text) typ
in in
let res_trans = fill_typ_with_zero var_exp_typ in let res_trans = fill_typ_with_zero var_exp_typ in
{res_trans with control= {res_trans.control with initd_exps= [fst var_exp_typ]}} {res_trans with control= {res_trans.control with initd_exps= [fst var_exp_typ]}}
| None -> | None ->
CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range
"Retrieving var from non-InitListExpr parent" "Retrieving var from non-InitListExpr parent"
@ -534,7 +534,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
assert false ) assert false )
| _ as decl -> | _ as decl ->
(* FIXME(t21762295): we do not expect this to happen but it does *) (* FIXME(t21762295): we do not expect this to happen but it does *)
CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range
"di_parent_pointer should be always set for fields/ivars, but got %a" "di_parent_pointer should be always set for fields/ivars, but got %a"
(Pp.option (Pp.to_string ~f:Clang_ast_j.string_of_decl)) (Pp.option (Pp.to_string ~f:Clang_ast_j.string_of_decl))
decl decl
@ -807,7 +807,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| (`CXXMethod | `CXXConversion | `CXXConstructor | `CXXDestructor), _ -> | (`CXXMethod | `CXXConversion | `CXXConstructor | `CXXDestructor), _ ->
method_deref_trans trans_state ~context decl_ref stmt_info decl_kind method_deref_trans trans_state ~context decl_ref stmt_info decl_kind
| _ -> | _ ->
CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range
"Decl ref expression %a with pointer %d still needs to be translated" "Decl ref expression %a with pointer %d still needs to be translated"
(Pp.to_string ~f:Clang_ast_j.string_of_decl_kind) (Pp.to_string ~f:Clang_ast_j.string_of_decl_kind)
decl_kind decl_ref.Clang_ast_t.dr_decl_pointer decl_kind decl_ref.Clang_ast_t.dr_decl_pointer
@ -1593,7 +1593,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
if root_nodes <> [] then {op_res_trans with control= {op_res_trans.control with root_nodes}} if root_nodes <> [] then {op_res_trans with control= {op_res_trans.control with root_nodes}}
else op_res_trans else op_res_trans
| _ -> | _ ->
CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range
"BinaryConditionalOperator not translated" "BinaryConditionalOperator not translated"
@ -2200,7 +2200,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| [stmt] -> | [stmt] ->
[init_expr_trans trans_state (var_exp, var_typ) stmt_info (Some stmt)] [init_expr_trans trans_state (var_exp, var_typ) stmt_info (Some stmt)]
| _ -> | _ ->
CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range
"InitListExpression for var %a type %a with multiple init statements" Exp.pp var_exp "InitListExpression for var %a type %a with multiple init statements" Exp.pp var_exp
(Typ.pp_full Pp.text) var_typ (Typ.pp_full Pp.text) var_typ
@ -2245,7 +2245,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| Tint _ | Tfloat _ | Tptr _ -> | Tint _ | Tfloat _ | Tptr _ ->
initListExpr_builtin_trans trans_state_pri init_stmt_info stmts var_exp var_typ initListExpr_builtin_trans trans_state_pri init_stmt_info stmts var_exp var_typ
| _ -> | _ ->
CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range
"InitListExp for var %a of type %a" Exp.pp var_exp (Typ.pp Pp.text) var_typ "InitListExp for var %a of type %a" Exp.pp var_exp (Typ.pp Pp.text) var_typ
in in
let res_trans = let res_trans =
@ -2408,7 +2408,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
:: _ -> :: _ ->
mk_trans_result (mk_fresh_void_exp_typ ()) empty_control mk_trans_result (mk_fresh_void_exp_typ ()) empty_control
| decl :: _ -> | decl :: _ ->
CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range
"In DeclStmt found an unknown declaration type %s" (Clang_ast_j.string_of_decl decl) "In DeclStmt found an unknown declaration type %s" (Clang_ast_j.string_of_decl decl)
| [] -> | [] ->
assert false assert false
@ -2431,7 +2431,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| Some stmt -> | Some stmt ->
instruction trans_state stmt instruction trans_state stmt
| None -> | None ->
CFrontend_config.incorrect_assumption __POS__ source_range CFrontend_errors.incorrect_assumption __POS__ source_range
"Expected source expression for OpaqueValueExpr" ) "Expected source expression for OpaqueValueExpr" )
@ -2793,7 +2793,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| Clang_ast_t.VarDecl (_, _, _, {vdi_init_expr}) -> | Clang_ast_t.VarDecl (_, _, _, {vdi_init_expr}) ->
init_expr_trans trans_state (Exp.Lvar pvar, typ) stmt_info vdi_init_expr init_expr_trans trans_state (Exp.Lvar pvar, typ) stmt_info vdi_init_expr
| _ -> | _ ->
CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range
"Capture-init statement without var decl" "Capture-init statement without var decl"
in in
let translate_normal_capture ~is_by_ref ((pvar, typ) as pvar_typ) let translate_normal_capture ~is_by_ref ((pvar, typ) as pvar_typ)
@ -2851,7 +2851,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
translate_normal_capture ~is_by_ref this_typ acc translate_normal_capture ~is_by_ref this_typ acc
else acc else acc
| None, Some _ -> | None, Some _ ->
CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range
"Capture-init with init, but no capture" "Capture-init with init, but no capture"
in in
let lei_captures = CMethod_trans.get_captures_from_cpp_lambda lei_lambda_decl in let lei_captures = CMethod_trans.get_captures_from_cpp_lambda lei_lambda_decl in
@ -3200,12 +3200,12 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| NullStmt _, `FallThroughAttr _ -> | NullStmt _, `FallThroughAttr _ ->
no_op_trans trans_state.succ_nodes no_op_trans trans_state.succ_nodes
| _ -> | _ ->
CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range
"attributedStmt [stmt] [attr] with:@\nstmt=%s@\nattr=%s@\n" "attributedStmt [stmt] [attr] with:@\nstmt=%s@\nattr=%s@\n"
(Clang_ast_j.string_of_stmt stmt) (Clang_ast_j.string_of_stmt stmt)
(Clang_ast_j.string_of_attribute attr) ) (Clang_ast_j.string_of_attribute attr) )
| _ -> | _ ->
CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range
"attributedStmt with:@\nstmts=[%a]@\nattrs=[%a]@\n" "attributedStmt with:@\nstmts=[%a]@\nattrs=[%a]@\n"
(Pp.semicolon_seq (Pp.to_string ~f:Clang_ast_j.string_of_stmt)) (Pp.semicolon_seq (Pp.to_string ~f:Clang_ast_j.string_of_stmt))
stmts stmts
@ -3223,7 +3223,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| Some {control= {root_nodes= []}} | None -> | Some {control= {root_nodes= []}} | None ->
mk_trans_result (mk_fresh_void_exp_typ ()) {empty_control with root_nodes= bn.break} ) mk_trans_result (mk_fresh_void_exp_typ ()) {empty_control with root_nodes= bn.break} )
| None (* t21762295 *) -> | None (* t21762295 *) ->
CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range
"Break stmt without continuation: %a" "Break stmt without continuation: %a"
(Pp.to_string ~f:Clang_ast_j.string_of_stmt_info) (Pp.to_string ~f:Clang_ast_j.string_of_stmt_info)
stmt_info stmt_info
@ -3240,7 +3240,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
mk_trans_result (mk_fresh_void_exp_typ ()) {empty_control with root_nodes= bn.continue} mk_trans_result (mk_fresh_void_exp_typ ()) {empty_control with root_nodes= bn.continue}
) )
| None (* t21762295 *) -> | None (* t21762295 *) ->
CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range
"Continue stmt without continuation: %a" "Continue stmt without continuation: %a"
(Pp.to_string ~f:Clang_ast_j.string_of_stmt_info) (Pp.to_string ~f:Clang_ast_j.string_of_stmt_info)
stmt_info stmt_info
@ -3325,7 +3325,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
Config.debug_level_capture >= 1 Config.debug_level_capture >= 1
|| ||
match e with match e with
| CFrontend_config.Unimplemented _ | CFrontend_config.IncorrectAssumption _ -> | CFrontend_errors.Unimplemented _ | CFrontend_errors.IncorrectAssumption _ ->
(* these are caught by default, do not print messages unless asked to do so *) (* these are caught by default, do not print messages unless asked to do so *)
false false
| _ -> | _ ->
@ -3609,7 +3609,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
(* Infer somehow ended up in templated non instantiated code - right now (* Infer somehow ended up in templated non instantiated code - right now
it's not supported and failure in those cases is expected. *) it's not supported and failure in those cases is expected. *)
| CXXDependentScopeMemberExpr ({Clang_ast_t.si_source_range}, _, _) -> | CXXDependentScopeMemberExpr ({Clang_ast_t.si_source_range}, _, _) ->
CFrontend_config.unimplemented __POS__ si_source_range CFrontend_errors.unimplemented __POS__ si_source_range
~ast_node:(Clang_ast_proj.get_stmt_kind_string instr) ~ast_node:(Clang_ast_proj.get_stmt_kind_string instr)
"Translation of templated code is unsupported: %a" "Translation of templated code is unsupported: %a"
(Pp.to_string ~f:Clang_ast_j.string_of_stmt) (Pp.to_string ~f:Clang_ast_j.string_of_stmt)
@ -3618,7 +3618,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| WhileStmt ({Clang_ast_t.si_source_range}, _) | WhileStmt ({Clang_ast_t.si_source_range}, _)
| DoStmt ({Clang_ast_t.si_source_range}, _) | DoStmt ({Clang_ast_t.si_source_range}, _)
| ObjCForCollectionStmt ({Clang_ast_t.si_source_range}, _) -> | ObjCForCollectionStmt ({Clang_ast_t.si_source_range}, _) ->
CFrontend_config.incorrect_assumption __POS__ si_source_range "Unexpected shape for %a: %a" CFrontend_errors.incorrect_assumption __POS__ si_source_range "Unexpected shape for %a: %a"
(Pp.to_string ~f:Clang_ast_proj.get_stmt_kind_string) (Pp.to_string ~f:Clang_ast_proj.get_stmt_kind_string)
instr instr
(Pp.to_string ~f:Clang_ast_j.string_of_stmt) (Pp.to_string ~f:Clang_ast_j.string_of_stmt)

@ -412,7 +412,7 @@ let dereference_value_from_result ?(strip_pointer = false) source_range sil_loc
| Tptr (typ, _) -> | Tptr (typ, _) ->
typ typ
| _ -> | _ ->
CFrontend_config.incorrect_assumption __POS__ source_range CFrontend_errors.incorrect_assumption __POS__ source_range
"Expected pointer type but found type %a" (Typ.pp_full Pp.text) class_typ "Expected pointer type but found type %a" (Typ.pp_full Pp.text) class_typ
in in
let cast_typ = if strip_pointer then typ_no_ptr else class_typ in let cast_typ = if strip_pointer then typ_no_ptr else class_typ in

@ -48,7 +48,7 @@ let sil_var_of_decl_ref context source_range decl_ref procname =
sil_var_of_decl context var_decl procname sil_var_of_decl context var_decl procname
| None -> | None ->
(* FIXME(t21762295) *) (* FIXME(t21762295) *)
CFrontend_config.incorrect_assumption __POS__ source_range CFrontend_errors.incorrect_assumption __POS__ source_range
"pointer '%d' for var decl not found. The var decl was: %a" pointer "pointer '%d' for var decl not found. The var decl was: %a" pointer
(Pp.to_string ~f:Clang_ast_j.string_of_decl_ref) (Pp.to_string ~f:Clang_ast_j.string_of_decl_ref)
decl_ref ) decl_ref )

Loading…
Cancel
Save