diff --git a/facebook-clang-plugins b/facebook-clang-plugins index eeac101a4..dc42763b2 160000 --- a/facebook-clang-plugins +++ b/facebook-clang-plugins @@ -1 +1 @@ -Subproject commit eeac101a411b4c82380cbcf326c13fa75f5b2063 +Subproject commit dc42763b2e43d19518b6d69554a606bb7eaa0f29 diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index 97d4c9717..ee5e86907 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -268,6 +268,7 @@ let get_struct_decls decl = | IndirectFieldDecl _ | OMPDeclareReductionDecl _ | UnresolvedUsingValueDecl _ + | OMPRequiresDecl _ | OMPThreadPrivateDecl _ | ObjCPropertyImplDecl _ | PragmaCommentDecl _ diff --git a/infer/src/clang/ClangCommand.ml b/infer/src/clang/ClangCommand.ml index ea3dcdbc4..4f20a797f 100644 --- a/infer/src/clang/ClangCommand.ml +++ b/infer/src/clang/ClangCommand.ml @@ -167,7 +167,7 @@ let clang_cc1_cmd_sanitizer cmd = | "-isystem" :: _, arg -> ( match isystem_to_override_regex with | Some isystem_to_override_regex when Str.string_match isystem_to_override_regex arg 0 -> - fcp_dir ^/ "clang" ^/ "install" ^/ "lib" ^/ "clang" ^/ "7.0.1" ^/ "include" + fcp_dir ^/ "clang" ^/ "install" ^/ "lib" ^/ "clang" ^/ "8.0.0" ^/ "include" | _ -> arg ) | "-I" :: _, arg -> ( diff --git a/infer/src/clang/ComponentKit.ml b/infer/src/clang/ComponentKit.ml index 2bd0e68ea..4c0332bd0 100644 --- a/infer/src/clang/ComponentKit.ml +++ b/infer/src/clang/ComponentKit.ml @@ -280,9 +280,7 @@ let component_with_unconventional_superclass_advice context an = Given n factory methods, the rule should emit n-1 issues. Each issue's location should point to the method declaration. *) let component_with_multiple_factory_methods_advice context an = - let is_unavailable_attr attr = - match attr with Clang_ast_t.UnavailableAttr _ -> true | _ -> false - in + let is_unavailable_attr attr = match attr with `UnavailableAttr _ -> true | _ -> false in let is_available_factory_method if_decl (decl : Clang_ast_t.decl) = match decl with | ObjCMethodDecl (decl_info, _, _) -> diff --git a/infer/src/clang/cAst_utils.ml b/infer/src/clang/cAst_utils.ml index c40813060..964ce8bb7 100644 --- a/infer/src/clang/cAst_utils.ml +++ b/infer/src/clang/cAst_utils.ml @@ -6,7 +6,6 @@ *) open! IStd -open PolyVariantEqual (** Functions for transformations of ast nodes *) @@ -116,6 +115,14 @@ let get_stmt stmt_ptr source_range = stmt +let get_stmt_exn stmt_ptr source_range = + match get_stmt stmt_ptr source_range with + | Some stmt -> + stmt + | None -> + L.die InternalError "statement clang pointer %d not found" stmt_ptr + + let get_stmt_opt stmt_ptr_opt source_range = match stmt_ptr_opt with Some stmt_ptr -> get_stmt stmt_ptr source_range | None -> None @@ -200,11 +207,10 @@ let sil_annot_of_type {Clang_ast_t.qt_type_ptr} = in let annot_name_opt = match get_type qt_type_ptr with - | Some (AttributedType (_, attr_info)) -> - if attr_info.ati_attr_kind = `Nullable then Some Annotations.nullable - else if attr_info.ati_attr_kind = `Nonnull then Some Annotations.nonnull - (* other annotations go here *) - else None + | Some (AttributedType (_, {ati_attr_kind= TypeNullableAttrKind})) -> + Some Annotations.nullable + | Some (AttributedType (_, {ati_attr_kind= TypeNonNullAttrKind})) -> + Some Annotations.nonnull | _ -> None in @@ -545,7 +551,7 @@ let has_block_attribute decl = match decl with | VarDecl (decl_info, _, _, _) -> let attributes = decl_info.di_attributes in - List.exists ~f:(fun attr -> match attr with BlocksAttr _ -> true | _ -> false) attributes + List.exists ~f:(fun attr -> match attr with `BlocksAttr _ -> true | _ -> false) attributes | _ -> false diff --git a/infer/src/clang/cAst_utils.mli b/infer/src/clang/cAst_utils.mli index dbbeec715..b83e30e87 100644 --- a/infer/src/clang/cAst_utils.mli +++ b/infer/src/clang/cAst_utils.mli @@ -21,6 +21,8 @@ val get_decl_opt : Clang_ast_t.pointer option -> Clang_ast_t.decl option val get_stmt : Clang_ast_t.pointer -> Clang_ast_t.source_range -> Clang_ast_t.stmt option +val get_stmt_exn : Clang_ast_t.pointer -> Clang_ast_t.source_range -> Clang_ast_t.stmt + val get_stmt_opt : Clang_ast_t.pointer option -> Clang_ast_t.source_range -> Clang_ast_t.stmt option diff --git a/infer/src/clang/cFrontend_checkers_main.ml b/infer/src/clang/cFrontend_checkers_main.ml index 6f6ef320d..c8a39ae4b 100644 --- a/infer/src/clang/cFrontend_checkers_main.ml +++ b/infer/src/clang/cFrontend_checkers_main.ml @@ -259,13 +259,20 @@ let rec do_frontend_checks_stmt linters (context : CLintersContext.context) [(context, lstmt @ [stmt])] | _ -> [(context, lstmt)] ) - | IfStmt (_, [stmt1; stmt2; cond_stmt; inside_if_stmt; inside_else_stmt]) -> - let inside_if_stmt_context = + | IfStmt (stmt_info, _, {Clang_ast_t.isi_cond; isi_cond_var; isi_then; isi_else}) -> + let cond_stmt = CAst_utils.get_stmt_exn isi_cond stmt_info.si_source_range in + let inside_then_stmt_context = {context with CLintersContext.if_context= compute_if_context context cond_stmt} in + let then_stmt = CAst_utils.get_stmt_exn isi_then stmt_info.si_source_range in + let other_stmts = + Option.to_list isi_cond_var + @ ( Option.map isi_else ~f:(fun (else_body, _) -> + CAst_utils.get_stmt_exn else_body stmt_info.si_source_range ) + |> Option.to_list ) + in (* distinguish between then and else branch as they need different context *) - [ (context, [stmt1; stmt2; cond_stmt; inside_else_stmt]) - ; (inside_if_stmt_context, [inside_if_stmt]) ] + [(context, cond_stmt :: other_stmts); (inside_then_stmt_context, [then_stmt])] | ForStmt (_, stmt1 :: stmts) -> let inside_for_stmt_decl_context = {context with CLintersContext.in_for_loop_declaration= true} diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index 817f4e11a..dda89868c 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -264,6 +264,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron | IndirectFieldDecl _ | OMPDeclareReductionDecl _ | UnresolvedUsingValueDecl _ + | OMPRequiresDecl _ | OMPThreadPrivateDecl _ | PragmaCommentDecl _ | PragmaDetectMismatchDecl _ diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index 8f7cbb664..53a0e3397 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -127,14 +127,8 @@ let sil_func_attributes_of_attributes attrs = match al with | [] -> List.rev acc - | Clang_ast_t.SentinelAttr attribute_info :: tl -> - let sentinel, null_pos = - match attribute_info.Clang_ast_t.ai_parameters with - | [a; b] -> - (int_of_string a, int_of_string b) - | _ -> - assert false - in + | `SentinelAttr (_attr_info, {Clang_ast_t.sai_sentinel= sentinel; sai_null_pos= null_pos}) + :: tl -> do_translation (PredSymb.FA_sentinel (sentinel, null_pos) :: acc) tl | _ :: tl -> do_translation acc tl diff --git a/infer/src/clang/cPredicates.ml b/infer/src/clang/cPredicates.ml index a88ad7b0e..7a66c5998 100644 --- a/infer/src/clang/cPredicates.ml +++ b/infer/src/clang/cPredicates.ml @@ -76,27 +76,17 @@ let declaration_name decl = let get_available_attr_ios_sdk an = - let open Clang_ast_t in - let rec get_available_attr attrs = - match attrs with - | [] -> - None - | AvailabilityAttr attr_info :: rest -> ( - match attr_info.ai_parameters with - | "ios" :: version :: _ -> - Some - (String.Search_pattern.replace_all - (String.Search_pattern.create "_") - ~in_:version ~with_:".") - | _ -> - get_available_attr rest ) - | _ :: rest -> - get_available_attr rest - in match an with | Ctl_parser_types.Decl decl -> let decl_info = Clang_ast_proj.get_decl_tuple decl in - get_available_attr decl_info.di_attributes + List.find_map decl_info.di_attributes ~f:(function + | `AvailabilityAttr (_attr_info, {Clang_ast_t.aai_platform= Some "ios"; aai_introduced}) -> + let get_opt_number = Option.value ~default:0 in + Some + (Printf.sprintf "%d.%d" aai_introduced.vt_major + (get_opt_number aai_introduced.vt_minor)) + | _ -> + None ) | _ -> None @@ -1385,33 +1375,38 @@ let rec get_decl_attributes_for_callexpr an = [] +let visibility_matches vis_str (visibility : Clang_ast_t.visibility_attr) = + match (visibility, vis_str) with + | DefaultVisibility, "Default" -> + true + | HiddenVisibility, "Hidden" -> + true + | ProtectedVisibility, "Protected" -> + true + | _ -> + false + + let has_visibility_attribute an visibility = - let open Clang_ast_t in - let rec has_visibility_attr attrs param = - match attrs with - | [] -> - false - | VisibilityAttr attr_info :: rest -> - if List.exists ~f:(fun s -> String.equal param (String.strip s)) attr_info.ai_parameters - then true - else has_visibility_attr rest param - | _ :: rest -> - has_visibility_attr rest param + let has_visibility_attr attrs param = + List.exists attrs ~f:(function + | `VisibilityAttr (_attr_info, visibility) -> + visibility_matches param visibility + | _ -> + false ) in let attributes = get_decl_attributes_for_callexpr an in match visibility with ALVar.Const vis -> has_visibility_attr attributes vis | _ -> false let has_used_attribute an = - let open Clang_ast_t in let attributes = get_decl_attributes_for_callexpr an in - List.exists ~f:(fun attr -> match attr with UsedAttr _ -> true | _ -> false) attributes + List.exists ~f:(fun attr -> match attr with `UsedAttr _ -> true | _ -> false) attributes (* true is a declaration has an Unavailable attribute *) let has_unavailable_attribute an = - let open Clang_ast_t in - let is_unavailable_attr attr = match attr with UnavailableAttr _ -> true | _ -> false in + let is_unavailable_attr attr = match attr with `UnavailableAttr _ -> true | _ -> false in match an with | Ctl_parser_types.Decl d -> let attrs = (Clang_ast_proj.get_decl_tuple d).di_attributes in diff --git a/infer/src/clang/cTL.ml b/infer/src/clang/cTL.ml index 5da9a7f44..af3fbbc8e 100644 --- a/infer/src/clang/cTL.ml +++ b/infer/src/clang/cTL.ml @@ -762,10 +762,12 @@ let transition_decl_to_decl_via_protocol d = let transition_stmt_to_stmt_via_condition st = let open Clang_ast_t in match st with - | IfStmt (_, _ :: _ :: cond :: _) + | IfStmt (stmt_info, _, {isi_cond; _}) -> + let cond = CAst_utils.get_stmt_exn isi_cond stmt_info.si_source_range in + [Stmt cond] | ConditionalOperator (_, cond :: _, _) | ForStmt (_, [_; _; cond; _; _]) - | WhileStmt (_, [_; cond; _]) -> + | WhileStmt (_, ([_; cond; _] | [cond; _])) -> [Stmt cond] | _ -> [] diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index c81014b6c..d188b99da 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -460,7 +460,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s let nbytes = match size with `SizeOfWithSize nbytes -> Some nbytes | _ -> None in let sizeof_data = {Exp.typ; nbytes; dynamic_length= None; subtype= Subtype.exact} in mk_trans_result (Exp.Sizeof sizeof_data, typ) empty_control - | `AlignOf | `OpenMPRequiredSimdAlign | `VecStep -> + | `AlignOf | `OpenMPRequiredSimdAlign | `PreferredAlignOf | `VecStep -> let nondet = (Exp.Var (Ident.create_fresh Ident.knormal), typ) in mk_trans_result nondet empty_control @@ -481,18 +481,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s let get_annotate_attr_arg decl = let open Clang_ast_t in let decl_info = Clang_ast_proj.get_decl_tuple decl in - let get_attr_opt = function AnnotateAttr a -> Some a | _ -> None in - match List.find_map ~f:get_attr_opt decl_info.di_attributes with - | Some attribute_info -> ( - match attribute_info.ai_parameters with - | [_; arg; _] -> - Some arg - | _ -> - (* it's not supposed to happen due to hardcoded exporting logic - coming from ASTExporter.h in facebook-clang-plugins *) - assert false ) - | None -> - None + let get_attr_opt = function `AnnotateAttr (_, annotation) -> Some annotation | _ -> None in + List.find_map ~f:get_attr_opt decl_info.di_attributes in let name = QualifiedCppName.to_qual_string qual_name in let function_attr_opt = Option.bind decl_opt ~f:get_annotate_attr_arg in @@ -1753,18 +1743,15 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s res_trans_cond - and ifStmt_trans trans_state stmt_info stmt_list = + and ifStmt_trans trans_state stmt_info (if_stmt_info : Clang_ast_t.if_stmt_info) = let context = trans_state.context in - let succ_nodes = trans_state.succ_nodes in + let source_range = stmt_info.Clang_ast_t.si_source_range in let sil_loc = CLocation.location_of_stmt_info context.translation_unit_context.source_file stmt_info in - let join_node = Procdesc.create_node context.procdesc sil_loc Procdesc.Node.Join_node [] in - Procdesc.node_set_succs_exn context.procdesc join_node succ_nodes [] ; - let trans_state' = {trans_state with succ_nodes= [join_node]} in - let do_branch branch stmt_branch prune_nodes = + let do_branch branch stmt_branch prune_nodes trans_state = (* leaf nodes are ignored here as they will be already attached to join_node *) - let res_trans_b = instruction trans_state' stmt_branch in + let res_trans_b = instruction trans_state stmt_branch in let nodes_branch = match res_trans_b.control.root_nodes with | [] -> @@ -1779,27 +1766,63 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s ~f:(fun n -> Procdesc.node_set_succs_exn context.procdesc n nodes_branch []) prune_nodes' in - match stmt_list with - | [_; decl_stmt; cond; stmt1; stmt2] -> - (* set the flat to inform that we are translating a condition of a if *) - let continuation' = mk_cond_continuation trans_state.continuation in - let trans_state'' = {trans_state with continuation= continuation'; succ_nodes= []} in - let res_trans_cond = cond_trans ~if_kind:Sil.Ik_if ~negate_cond:false trans_state'' cond in - let res_trans_decl = declStmt_in_condition_trans trans_state decl_stmt res_trans_cond in - (* Note: by contruction prune nodes are leafs_nodes_cond *) - do_branch true stmt1 res_trans_cond.control.leaf_nodes ; - do_branch false stmt2 res_trans_cond.control.leaf_nodes ; - mk_trans_result (mk_fresh_void_exp_typ ()) - { empty_control with - root_nodes= res_trans_decl.control.root_nodes - ; leaf_nodes= [join_node] } - | _ -> - assert false + let join_node = Procdesc.create_node context.procdesc sil_loc Procdesc.Node.Join_node [] in + Procdesc.node_set_succs_exn context.procdesc join_node trans_state.succ_nodes [] ; + let trans_state_join_succ = {trans_state with succ_nodes= [join_node]} in + (* translate the condition expression *) + let res_trans_cond = + (* set the flag to inform that we are translating a condition of an "if" *) + let continuation' = mk_cond_continuation trans_state.continuation in + let trans_state'' = {trans_state with continuation= continuation'; succ_nodes= []} in + let cond_stmt = CAst_utils.get_stmt_exn if_stmt_info.isi_cond source_range in + cond_trans ~if_kind:Sil.Ik_if ~negate_cond:false trans_state'' cond_stmt + in + (* translate the variable declaration inside the condition if present *) + let res_trans_cond_var = + match if_stmt_info.isi_cond_var with + | Some cond_var -> + declStmt_in_condition_trans trans_state cond_var res_trans_cond + | None -> + res_trans_cond + in + let then_body = CAst_utils.get_stmt_exn if_stmt_info.isi_then source_range in + (* Note: by contruction prune nodes are leafs_nodes_cond *) + do_branch true then_body res_trans_cond.control.leaf_nodes trans_state_join_succ ; + let else_body = + match if_stmt_info.isi_else with + | None -> + Clang_ast_t.NullStmt (stmt_info, []) + | Some (else_body_ptr, _) -> + CAst_utils.get_stmt_exn else_body_ptr source_range + in + do_branch false else_body res_trans_cond.control.leaf_nodes trans_state_join_succ ; + (* translate the initialisation if present *) + let res_trans_init = + match if_stmt_info.isi_init with + | Some init_stmt_ptr -> + let init_stmt = CAst_utils.get_stmt_exn init_stmt_ptr source_range in + instruction + {trans_state with succ_nodes= res_trans_cond_var.control.root_nodes} + init_stmt + | None -> + res_trans_cond_var + in + let root_nodes = res_trans_init.control.root_nodes in + mk_trans_result (mk_fresh_void_exp_typ ()) + {empty_control with root_nodes; leaf_nodes= [join_node]} and caseStmt_trans trans_state stmt_info case_stmt_list = - (* ignore the [case lhs ... rhs: body] form, only support the [case condition: body] form *) - let[@warning "-8"] [condition; _rhs; body] = case_stmt_list in + let condition, body = + match case_stmt_list with + | [condition; body] -> + (condition, body) + | [condition; _rhs; body] -> + (* ignore the [case lhs ... rhs: body] form, only support the [case condition: body] form *) + (condition, body) + | _ -> + assert false + in let body_trans_result = instruction trans_state body in (let open SwitchCase in add {condition= Case condition; stmt_info; root_nodes= body_trans_result.control.root_nodes}) ; @@ -1814,12 +1837,19 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s body_trans_result - and switchStmt_trans trans_state stmt_info switch_stmt_list = + and switchStmt_trans trans_state stmt_info switch_stmt_info = (* overview: translate the body of the switch statement, which automatically collects the various cases at the same time, then link up the cases together and together with the switch condition variable *) (* unsupported: initialization *) - let[@warning "-8"] [_initialization; variable; condition; body] = switch_stmt_list in + let condition = + CAst_utils.get_stmt_exn switch_stmt_info.Clang_ast_t.ssi_cond + stmt_info.Clang_ast_t.si_source_range + in + let body = + CAst_utils.get_stmt_exn switch_stmt_info.Clang_ast_t.ssi_body + stmt_info.Clang_ast_t.si_source_range + in let context = trans_state.context in let sil_loc = CLocation.location_of_stmt_info context.translation_unit_context.source_file stmt_info @@ -1843,7 +1873,13 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s { res_trans_cond_tmp with control= {res_trans_cond_tmp.control with root_nodes; leaf_nodes= [switch_node]} } in - let variable_result = declStmt_in_condition_trans trans_state variable condition_result in + let variable_result = + match switch_stmt_info.Clang_ast_t.ssi_cond_var with + | None -> + condition_result + | Some variable -> + declStmt_in_condition_trans trans_state variable condition_result + in let trans_state_no_pri = if PriorityNode.own_priority_node trans_state_pri.priority stmt_info then {trans_state_pri with priority= Free} @@ -1983,9 +2019,9 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s let res_trans_cond = cond_trans ~if_kind ~negate_cond:false trans_state_cond cond_stmt in let res_trans_decl = match loop_kind with - | Loops.For {decl_stmt} | Loops.While {decl_stmt} -> + | Loops.For {decl_stmt} | Loops.While {decl_stmt= Some decl_stmt} -> declStmt_in_condition_trans trans_state decl_stmt res_trans_cond - | Loops.DoWhile _ -> + | Loops.While {decl_stmt= None} | Loops.DoWhile _ -> res_trans_cond in let body_succ_nodes = @@ -2081,8 +2117,14 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s and cxxForRangeStmt_trans trans_state stmt_info stmt_list = let open Clang_ast_t in match stmt_list with - | [iterator_decl; begin_stmt; end_stmt; exit_cond; increment; assign_current_index; loop_body] - -> + | [ _init + ; iterator_decl + ; begin_stmt + ; end_stmt + ; exit_cond + ; increment + ; assign_current_index + ; loop_body ] -> let loop_body' = CompoundStmt (stmt_info, [assign_current_index; loop_body]) in let null_stmt = NullStmt (stmt_info, []) in let beginend_stmt = CompoundStmt (stmt_info, [begin_stmt; end_stmt]) in @@ -2108,8 +2150,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s (* variable item but we still need to add the variable to the locals *) let assign_next_object, cond = Ast_expressions.make_next_object_exp stmt_info item items in let body' = Clang_ast_t.CompoundStmt (stmt_info, [body; assign_next_object]) in - let null_stmt = Clang_ast_t.NullStmt (stmt_info, []) in - let loop = Clang_ast_t.WhileStmt (stmt_info, [null_stmt; cond; body']) in + let loop = Clang_ast_t.WhileStmt (stmt_info, [cond; body']) in instruction trans_state (Clang_ast_t.CompoundStmt (stmt_info, [assign_next_object; loop])) @@ -2306,7 +2347,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s vdi.Clang_ast_t.vdi_init_expr in let has_unused_attr attributes = - List.exists attributes ~f:(function Clang_ast_t.UnusedAttr _ -> true | _ -> false) + List.exists attributes ~f:(function `UnusedAttr _ -> true | _ -> false) in let rec aux : decl list -> trans_result option = function | [] -> @@ -2683,11 +2724,11 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s instruction trans_state message_stmt - (* @synchronized(anObj) {body} is translated as - + (* @synchronized(anObj) {body} is translated as + __set_locked_attribue(anObj); body; - __delete_locked_attribute(anObj); + __delete_locked_attribute(anObj); *) and objCAtSynchronizedStmt_trans trans_state stmt_list stmt_info = match stmt_list with @@ -3152,7 +3193,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s match (stmts, attrs) with | [stmt], [attr] -> ( match (stmt, attr) with - | NullStmt _, FallThroughAttr _ -> + | NullStmt _, `FallThroughAttr _ -> no_op_trans trans_state.succ_nodes | _ -> CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range @@ -3286,6 +3327,13 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s binaryOperator_trans_with_cond trans_state stmt_info stmt_list expr_info binop_info | CallExpr (stmt_info, stmt_list, ei) | UserDefinedLiteral (stmt_info, stmt_list, ei) -> callExpr_trans trans_state stmt_info stmt_list ei + | ConstantExpr (_, stmt_list, _) -> ( + match stmt_list with + | [stmt] -> + instruction_aux trans_state stmt + | stmts -> + L.die InternalError "Expected exactly one statement in ConstantExpr, got %d" + (List.length stmts) ) | CXXMemberCallExpr (stmt_info, stmt_list, ei) -> cxxMemberCallExpr_trans trans_state stmt_info stmt_list ei | CXXOperatorCallExpr (stmt_info, stmt_list, ei) -> @@ -3306,10 +3354,10 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | ConditionalOperator (stmt_info, stmt_list, expr_info) -> (* Ternary operator "cond ? exp1 : exp2" *) conditionalOperator_trans trans_state stmt_info stmt_list expr_info - | IfStmt (stmt_info, stmt_list) -> - ifStmt_trans trans_state stmt_info stmt_list - | SwitchStmt (stmt_info, switch_stmt_list) -> - switchStmt_trans trans_state stmt_info switch_stmt_list + | IfStmt (stmt_info, _, if_stmt_info) -> + ifStmt_trans trans_state stmt_info if_stmt_info + | SwitchStmt (stmt_info, _, switch_stmt_info) -> + switchStmt_trans trans_state stmt_info switch_stmt_info | CaseStmt (stmt_info, stmt_list) -> caseStmt_trans trans_state stmt_info stmt_list | DefaultStmt (stmt_info, stmt_list) -> @@ -3318,8 +3366,10 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s stmtExpr_trans trans_state si_source_range stmt_list | ForStmt (stmt_info, [init; decl_stmt; condition; increment; body]) -> forStmt_trans trans_state ~init ~decl_stmt ~condition ~increment ~body stmt_info + | WhileStmt (stmt_info, [condition; body]) -> + whileStmt_trans trans_state ~decl_stmt:None ~condition ~body stmt_info | WhileStmt (stmt_info, [decl_stmt; condition; body]) -> - whileStmt_trans trans_state ~decl_stmt ~condition ~body stmt_info + whileStmt_trans trans_state ~decl_stmt:(Some decl_stmt) ~condition ~body stmt_info | DoStmt (stmt_info, [body; condition]) -> doStmt_trans trans_state ~condition ~body stmt_info | CXXForRangeStmt (stmt_info, stmt_list) -> diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index 72075e1c4..518384fd8 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -257,7 +257,10 @@ module Loops = struct ; condition: Clang_ast_t.stmt ; increment: Clang_ast_t.stmt ; body: Clang_ast_t.stmt } - | While of {decl_stmt: Clang_ast_t.stmt; condition: Clang_ast_t.stmt; body: Clang_ast_t.stmt} + | While of + { decl_stmt: Clang_ast_t.stmt option + ; condition: Clang_ast_t.stmt + ; body: Clang_ast_t.stmt } | DoWhile of {condition: Clang_ast_t.stmt; body: Clang_ast_t.stmt} let get_body loop_kind = @@ -312,10 +315,10 @@ module Scope = struct | BreakStmt (stmt_info, _) | ContinueStmt (stmt_info, _) -> let vars_to_destroy = List.take vars_in_scope (List.length vars_in_scope - break_count) in add_scope_vars_to_destroy var_map stmt_info vars_to_destroy + (* TODO handle variable declarations inside for / foreach / while / switch *) | WhileStmt (_, stmt_list) | DoStmt (_, stmt_list) - | SwitchStmt (_, stmt_list) - (* TODO handle variable declarations inside for / foreach *) + | SwitchStmt (_, stmt_list, _) | ForStmt (_, stmt_list) | CXXForRangeStmt (_, stmt_list) -> let break_count = List.length vars_in_scope in diff --git a/infer/src/clang/cTrans_utils.mli b/infer/src/clang/cTrans_utils.mli index 3c10a6d12..f5bd511b6 100644 --- a/infer/src/clang/cTrans_utils.mli +++ b/infer/src/clang/cTrans_utils.mli @@ -211,7 +211,10 @@ module Loops : sig ; condition: Clang_ast_t.stmt ; increment: Clang_ast_t.stmt ; body: Clang_ast_t.stmt } - | While of {decl_stmt: Clang_ast_t.stmt; condition: Clang_ast_t.stmt; body: Clang_ast_t.stmt} + | While of + { decl_stmt: Clang_ast_t.stmt option + ; condition: Clang_ast_t.stmt + ; body: Clang_ast_t.stmt } | DoWhile of {condition: Clang_ast_t.stmt; body: Clang_ast_t.stmt} val get_cond : loop_kind -> Clang_ast_t.stmt diff --git a/infer/src/clang/cVar_decl.ml b/infer/src/clang/cVar_decl.ml index 3db262f87..4cc7997b3 100644 --- a/infer/src/clang/cVar_decl.ml +++ b/infer/src/clang/cVar_decl.ml @@ -57,7 +57,7 @@ let sil_var_of_decl_ref context source_range decl_ref procname = let has_block_attribute decl_info = let open Clang_ast_t in List.exists decl_info.di_attributes ~f:(fun attr -> - match attr with BlocksAttr _ -> true | _ -> false ) + match attr with `BlocksAttr _ -> true | _ -> false ) let add_var_to_locals procdesc var_decl typ pvar = diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot index 8d880bc35..eb44f0400 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot @@ -124,7 +124,7 @@ digraph cfg { "main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ; -"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:std::basic_string,std::allocator>); [line 20, column 3]\n n$5=_fun_std::basic_string,std::allocator>::basic_string(&s:std::basic_string,std::allocator>*,\"1234\":char const *) [line 20, column 15]\n EXIT_SCOPE(n$5); [line 20, column 15]\n " shape="box"] +"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:std::basic_string,std::allocator>); [line 20, column 3]\n n$5=_fun_std::basic_string,std::allocator>::basic_string(&s:std::basic_string,std::allocator>*,\"1234\":char const *) [line 20, column 15]\n EXIT_SCOPE(n$5); [line 20, column 15]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_4" -> "main.fad58de7366495db4650cfefac2fcd61_3" ; diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot index 8d880bc35..eb44f0400 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot @@ -124,7 +124,7 @@ digraph cfg { "main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ; -"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:std::basic_string,std::allocator>); [line 20, column 3]\n n$5=_fun_std::basic_string,std::allocator>::basic_string(&s:std::basic_string,std::allocator>*,\"1234\":char const *) [line 20, column 15]\n EXIT_SCOPE(n$5); [line 20, column 15]\n " shape="box"] +"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:std::basic_string,std::allocator>); [line 20, column 3]\n n$5=_fun_std::basic_string,std::allocator>::basic_string(&s:std::basic_string,std::allocator>*,\"1234\":char const *) [line 20, column 15]\n EXIT_SCOPE(n$5); [line 20, column 15]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_4" -> "main.fad58de7366495db4650cfefac2fcd61_3" ; diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot index 8d880bc35..eb44f0400 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot @@ -124,7 +124,7 @@ digraph cfg { "main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ; -"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:std::basic_string,std::allocator>); [line 20, column 3]\n n$5=_fun_std::basic_string,std::allocator>::basic_string(&s:std::basic_string,std::allocator>*,\"1234\":char const *) [line 20, column 15]\n EXIT_SCOPE(n$5); [line 20, column 15]\n " shape="box"] +"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:std::basic_string,std::allocator>); [line 20, column 3]\n n$5=_fun_std::basic_string,std::allocator>::basic_string(&s:std::basic_string,std::allocator>*,\"1234\":char const *) [line 20, column 15]\n EXIT_SCOPE(n$5); [line 20, column 15]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_4" -> "main.fad58de7366495db4650cfefac2fcd61_3" ; diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot index 8d880bc35..eb44f0400 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot @@ -124,7 +124,7 @@ digraph cfg { "main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ; -"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:std::basic_string,std::allocator>); [line 20, column 3]\n n$5=_fun_std::basic_string,std::allocator>::basic_string(&s:std::basic_string,std::allocator>*,\"1234\":char const *) [line 20, column 15]\n EXIT_SCOPE(n$5); [line 20, column 15]\n " shape="box"] +"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:std::basic_string,std::allocator>); [line 20, column 3]\n n$5=_fun_std::basic_string,std::allocator>::basic_string(&s:std::basic_string,std::allocator>*,\"1234\":char const *) [line 20, column 15]\n EXIT_SCOPE(n$5); [line 20, column 15]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_4" -> "main.fad58de7366495db4650cfefac2fcd61_3" ; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c.dot b/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c.dot index 5db3bb9e6..186dbcbd8 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c.dot @@ -23,7 +23,7 @@ digraph cfg { "main.fad58de7366495db4650cfefac2fcd61_6" -> "main.fad58de7366495db4650cfefac2fcd61_15" ; -"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: BinaryOperatorStmt: Assign \n n$1=_fun_getenv((char const *)\"BLOCK_SIZE\":char const *) [line 47, column 25]\n *&spec:char*=n$1 [line 47, column 18]\n n$2=*&spec:char* [line 47, column 18]\n EXIT_SCOPE(n$1); [line 47, column 18]\n " shape="box"] +"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: BinaryOperatorStmt: Assign \n n$1=_fun_getenv(\"BLOCK_SIZE\":char*) [line 47, column 25]\n *&spec:char*=n$1 [line 47, column 18]\n n$2=*&spec:char* [line 47, column 18]\n EXIT_SCOPE(n$1); [line 47, column 18]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_7" -> "main.fad58de7366495db4650cfefac2fcd61_8" ; @@ -36,7 +36,7 @@ digraph cfg { "main.fad58de7366495db4650cfefac2fcd61_9" -> "main.fad58de7366495db4650cfefac2fcd61_15" ; -"main.fad58de7366495db4650cfefac2fcd61_10" [label="10: BinaryOperatorStmt: Assign \n n$3=_fun_getenv((char const *)\"BLOCKSIZE\":char const *) [line 47, column 59]\n *&spec:char*=n$3 [line 47, column 52]\n n$4=*&spec:char* [line 47, column 52]\n EXIT_SCOPE(n$3); [line 47, column 52]\n " shape="box"] +"main.fad58de7366495db4650cfefac2fcd61_10" [label="10: BinaryOperatorStmt: Assign \n n$3=_fun_getenv(\"BLOCKSIZE\":char*) [line 47, column 59]\n *&spec:char*=n$3 [line 47, column 52]\n n$4=*&spec:char* [line 47, column 52]\n EXIT_SCOPE(n$3); [line 47, column 52]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_10" -> "main.fad58de7366495db4650cfefac2fcd61_11" ; @@ -74,7 +74,7 @@ digraph cfg { "main.fad58de7366495db4650cfefac2fcd61_18" -> "main.fad58de7366495db4650cfefac2fcd61_14" ; -"main.fad58de7366495db4650cfefac2fcd61_19" [label="19: BinaryOperatorStmt: Assign \n n$10=_fun_getenv((char const *)\"BLOCK\":char const *) [line 45, column 10]\n *&spec:char*=n$10 [line 45, column 3]\n EXIT_SCOPE(n$10); [line 45, column 3]\n " shape="box"] +"main.fad58de7366495db4650cfefac2fcd61_19" [label="19: BinaryOperatorStmt: Assign \n n$10=_fun_getenv(\"BLOCK\":char*) [line 45, column 10]\n *&spec:char*=n$10 [line 45, column 3]\n EXIT_SCOPE(n$10); [line 45, column 3]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_19" -> "main.fad58de7366495db4650cfefac2fcd61_5" ; @@ -103,7 +103,7 @@ digraph cfg { "shortcircuit_and.10f9635d805ff3bd29dfc80b8f8d12da_6" -> "shortcircuit_and.10f9635d805ff3bd29dfc80b8f8d12da_11" ; -"shortcircuit_and.10f9635d805ff3bd29dfc80b8f8d12da_7" [label="7: BinaryOperatorStmt: Assign \n n$2=_fun_getenv((char const *)\"BLOCK\":char const *) [line 20, column 19]\n *&x:int*=(int*)n$2 [line 20, column 15]\n n$3=*&x:int* [line 20, column 15]\n EXIT_SCOPE(n$2); [line 20, column 15]\n " shape="box"] +"shortcircuit_and.10f9635d805ff3bd29dfc80b8f8d12da_7" [label="7: BinaryOperatorStmt: Assign \n n$2=_fun_getenv(\"BLOCK\":char*) [line 20, column 19]\n *&x:int*=(int*)n$2 [line 20, column 15]\n n$3=*&x:int* [line 20, column 15]\n EXIT_SCOPE(n$2); [line 20, column 15]\n " shape="box"] "shortcircuit_and.10f9635d805ff3bd29dfc80b8f8d12da_7" -> "shortcircuit_and.10f9635d805ff3bd29dfc80b8f8d12da_8" ; @@ -193,7 +193,7 @@ digraph cfg { "test_loop.254a9d372f8f45542e409771135b9322_5" -> "test_loop.254a9d372f8f45542e409771135b9322_2" ; -"test_loop.254a9d372f8f45542e409771135b9322_6" [label="6: BinaryOperatorStmt: Assign \n n$1=_fun_getenv((char const *)\"BLOCK_SIZE\":char const *) [line 34, column 29]\n *&spec:char*=n$1 [line 34, column 22]\n n$2=*&spec:char* [line 34, column 22]\n NULLIFY(&spec); [line 34, column 22]\n EXIT_SCOPE(n$1,spec); [line 34, column 22]\n " shape="box"] +"test_loop.254a9d372f8f45542e409771135b9322_6" [label="6: BinaryOperatorStmt: Assign \n n$1=_fun_getenv(\"BLOCK_SIZE\":char*) [line 34, column 29]\n *&spec:char*=n$1 [line 34, column 22]\n n$2=*&spec:char* [line 34, column 22]\n NULLIFY(&spec); [line 34, column 22]\n EXIT_SCOPE(n$1,spec); [line 34, column 22]\n " shape="box"] "test_loop.254a9d372f8f45542e409771135b9322_6" -> "test_loop.254a9d372f8f45542e409771135b9322_7" ; @@ -206,7 +206,7 @@ digraph cfg { "test_loop.254a9d372f8f45542e409771135b9322_8" -> "test_loop.254a9d372f8f45542e409771135b9322_2" ; -"test_loop.254a9d372f8f45542e409771135b9322_9" [label="9: BinaryOperatorStmt: Assign \n n$3=_fun_getenv((char const *)\"BLOCKSIZE\":char const *) [line 35, column 20]\n *&spec:char*=n$3 [line 35, column 13]\n n$4=*&spec:char* [line 35, column 13]\n EXIT_SCOPE(n$3); [line 35, column 13]\n " shape="box"] +"test_loop.254a9d372f8f45542e409771135b9322_9" [label="9: BinaryOperatorStmt: Assign \n n$3=_fun_getenv(\"BLOCKSIZE\":char*) [line 35, column 20]\n *&spec:char*=n$3 [line 35, column 13]\n n$4=*&spec:char* [line 35, column 13]\n EXIT_SCOPE(n$3); [line 35, column 13]\n " shape="box"] "test_loop.254a9d372f8f45542e409771135b9322_9" -> "test_loop.254a9d372f8f45542e409771135b9322_10" ; @@ -223,7 +223,7 @@ digraph cfg { "test_loop.254a9d372f8f45542e409771135b9322_12" -> "test_loop.254a9d372f8f45542e409771135b9322_3" ; -"test_loop.254a9d372f8f45542e409771135b9322_13" [label="13: BinaryOperatorStmt: Assign \n n$6=_fun_getenv((char const *)\"BLOCK\":char const *) [line 32, column 10]\n *&spec:char*=n$6 [line 32, column 3]\n EXIT_SCOPE(n$6); [line 32, column 3]\n APPLY_ABSTRACTION; [line 32, column 3]\n " shape="box"] +"test_loop.254a9d372f8f45542e409771135b9322_13" [label="13: BinaryOperatorStmt: Assign \n n$6=_fun_getenv(\"BLOCK\":char*) [line 32, column 10]\n *&spec:char*=n$6 [line 32, column 3]\n EXIT_SCOPE(n$6); [line 32, column 3]\n APPLY_ABSTRACTION; [line 32, column 3]\n " shape="box"] "test_loop.254a9d372f8f45542e409771135b9322_13" -> "test_loop.254a9d372f8f45542e409771135b9322_3" ; diff --git a/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c.dot b/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c.dot index ec5d56586..7e7b15144 100644 --- a/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c.dot @@ -201,7 +201,7 @@ digraph cfg { "g3.8a9fd7dfda802921fdc4079f9a528ce8_3" -> "g3.8a9fd7dfda802921fdc4079f9a528ce8_2" ; -"g3.8a9fd7dfda802921fdc4079f9a528ce8_4" [label="4: Call _fun_printf \n n$0=_fun_printf((char const *)\"exit\\n\":char const *) [line 75, column 3]\n EXIT_SCOPE(n$0); [line 75, column 3]\n " shape="box"] +"g3.8a9fd7dfda802921fdc4079f9a528ce8_4" [label="4: Call _fun_printf \n n$0=_fun_printf(\"exit\\n\":char*) [line 75, column 3]\n EXIT_SCOPE(n$0); [line 75, column 3]\n " shape="box"] "g3.8a9fd7dfda802921fdc4079f9a528ce8_4" -> "g3.8a9fd7dfda802921fdc4079f9a528ce8_3" ; @@ -209,7 +209,7 @@ digraph cfg { "g3.8a9fd7dfda802921fdc4079f9a528ce8_5" -> "g3.8a9fd7dfda802921fdc4079f9a528ce8_4" ; -"g3.8a9fd7dfda802921fdc4079f9a528ce8_6" [label="6: Call _fun_printf \n n$2=_fun_printf((char const *)\"A\\n\":char const *) [line 72, column 3]\n EXIT_SCOPE(n$2); [line 72, column 3]\n APPLY_ABSTRACTION; [line 72, column 3]\n " shape="box"] +"g3.8a9fd7dfda802921fdc4079f9a528ce8_6" [label="6: Call _fun_printf \n n$2=_fun_printf(\"A\\n\":char*) [line 72, column 3]\n EXIT_SCOPE(n$2); [line 72, column 3]\n APPLY_ABSTRACTION; [line 72, column 3]\n " shape="box"] "g3.8a9fd7dfda802921fdc4079f9a528ce8_6" -> "g3.8a9fd7dfda802921fdc4079f9a528ce8_5" ; @@ -225,7 +225,7 @@ digraph cfg { "g3.8a9fd7dfda802921fdc4079f9a528ce8_9" -> "g3.8a9fd7dfda802921fdc4079f9a528ce8_2" ; -"g3.8a9fd7dfda802921fdc4079f9a528ce8_10" [label="10: Call _fun_printf \n n$4=_fun_printf((char const *)\"g3\\n\":char const *) [line 67, column 3]\n EXIT_SCOPE(n$4); [line 67, column 3]\n " shape="box"] +"g3.8a9fd7dfda802921fdc4079f9a528ce8_10" [label="10: Call _fun_printf \n n$4=_fun_printf(\"g3\\n\":char*) [line 67, column 3]\n EXIT_SCOPE(n$4); [line 67, column 3]\n " shape="box"] "g3.8a9fd7dfda802921fdc4079f9a528ce8_10" -> "g3.8a9fd7dfda802921fdc4079f9a528ce8_9" ; @@ -284,7 +284,7 @@ digraph cfg { "g3.8a9fd7dfda802921fdc4079f9a528ce8_23" -> "g3.8a9fd7dfda802921fdc4079f9a528ce8_20" ; -"g3.8a9fd7dfda802921fdc4079f9a528ce8_24" [label="24: Call _fun_printf \n n$17=_fun_printf((char const *)\"B\\n\":char const *) [line 59, column 3]\n EXIT_SCOPE(n$17); [line 59, column 3]\n " shape="box"] +"g3.8a9fd7dfda802921fdc4079f9a528ce8_24" [label="24: Call _fun_printf \n n$17=_fun_printf(\"B\\n\":char*) [line 59, column 3]\n EXIT_SCOPE(n$17); [line 59, column 3]\n " shape="box"] "g3.8a9fd7dfda802921fdc4079f9a528ce8_24" -> "g3.8a9fd7dfda802921fdc4079f9a528ce8_21" ; @@ -299,7 +299,7 @@ digraph cfg { "g4.b0b5c8f28ad7834e70a958a8882fa59a_3" -> "g4.b0b5c8f28ad7834e70a958a8882fa59a_2" ; -"g4.b0b5c8f28ad7834e70a958a8882fa59a_4" [label="4: Call _fun_printf \n n$0=_fun_printf((char const *)\"exit\\n\":char const *) [line 96, column 3]\n EXIT_SCOPE(n$0); [line 96, column 3]\n " shape="box"] +"g4.b0b5c8f28ad7834e70a958a8882fa59a_4" [label="4: Call _fun_printf \n n$0=_fun_printf(\"exit\\n\":char*) [line 96, column 3]\n EXIT_SCOPE(n$0); [line 96, column 3]\n " shape="box"] "g4.b0b5c8f28ad7834e70a958a8882fa59a_4" -> "g4.b0b5c8f28ad7834e70a958a8882fa59a_3" ; @@ -307,7 +307,7 @@ digraph cfg { "g4.b0b5c8f28ad7834e70a958a8882fa59a_5" -> "g4.b0b5c8f28ad7834e70a958a8882fa59a_4" ; -"g4.b0b5c8f28ad7834e70a958a8882fa59a_6" [label="6: Call _fun_printf \n n$2=_fun_printf((char const *)\"A\\n\":char const *) [line 93, column 3]\n EXIT_SCOPE(n$2); [line 93, column 3]\n APPLY_ABSTRACTION; [line 93, column 3]\n " shape="box"] +"g4.b0b5c8f28ad7834e70a958a8882fa59a_6" [label="6: Call _fun_printf \n n$2=_fun_printf(\"A\\n\":char*) [line 93, column 3]\n EXIT_SCOPE(n$2); [line 93, column 3]\n APPLY_ABSTRACTION; [line 93, column 3]\n " shape="box"] "g4.b0b5c8f28ad7834e70a958a8882fa59a_6" -> "g4.b0b5c8f28ad7834e70a958a8882fa59a_5" ; @@ -319,7 +319,7 @@ digraph cfg { "g4.b0b5c8f28ad7834e70a958a8882fa59a_8" -> "g4.b0b5c8f28ad7834e70a958a8882fa59a_7" ; -"g4.b0b5c8f28ad7834e70a958a8882fa59a_9" [label="9: Call _fun_printf \n n$4=_fun_printf((char const *)\"g4\\n\":char const *) [line 89, column 3]\n EXIT_SCOPE(n$4); [line 89, column 3]\n APPLY_ABSTRACTION; [line 89, column 3]\n " shape="box"] +"g4.b0b5c8f28ad7834e70a958a8882fa59a_9" [label="9: Call _fun_printf \n n$4=_fun_printf(\"g4\\n\":char*) [line 89, column 3]\n EXIT_SCOPE(n$4); [line 89, column 3]\n APPLY_ABSTRACTION; [line 89, column 3]\n " shape="box"] "g4.b0b5c8f28ad7834e70a958a8882fa59a_9" -> "g4.b0b5c8f28ad7834e70a958a8882fa59a_8" ; @@ -378,7 +378,7 @@ digraph cfg { "g4.b0b5c8f28ad7834e70a958a8882fa59a_22" -> "g4.b0b5c8f28ad7834e70a958a8882fa59a_19" ; -"g4.b0b5c8f28ad7834e70a958a8882fa59a_23" [label="23: Call _fun_printf \n n$17=_fun_printf((char const *)\"B\\n\":char const *) [line 81, column 3]\n EXIT_SCOPE(n$17); [line 81, column 3]\n " shape="box"] +"g4.b0b5c8f28ad7834e70a958a8882fa59a_23" [label="23: Call _fun_printf \n n$17=_fun_printf(\"B\\n\":char*) [line 81, column 3]\n EXIT_SCOPE(n$17); [line 81, column 3]\n " shape="box"] "g4.b0b5c8f28ad7834e70a958a8882fa59a_23" -> "g4.b0b5c8f28ad7834e70a958a8882fa59a_20" ; @@ -393,7 +393,7 @@ digraph cfg { "g5.37c965a8d6d7bec292c7b11ff315d9ea_3" -> "g5.37c965a8d6d7bec292c7b11ff315d9ea_8" ; -"g5.37c965a8d6d7bec292c7b11ff315d9ea_4" [label="4: Call _fun_printf \n n$1=_fun_printf((char const *)\"exit\\n\":char const *) [line 118, column 3]\n EXIT_SCOPE(n$1); [line 118, column 3]\n APPLY_ABSTRACTION; [line 118, column 3]\n " shape="box"] +"g5.37c965a8d6d7bec292c7b11ff315d9ea_4" [label="4: Call _fun_printf \n n$1=_fun_printf(\"exit\\n\":char*) [line 118, column 3]\n EXIT_SCOPE(n$1); [line 118, column 3]\n APPLY_ABSTRACTION; [line 118, column 3]\n " shape="box"] "g5.37c965a8d6d7bec292c7b11ff315d9ea_4" -> "g5.37c965a8d6d7bec292c7b11ff315d9ea_3" ; @@ -405,7 +405,7 @@ digraph cfg { "g5.37c965a8d6d7bec292c7b11ff315d9ea_6" -> "g5.37c965a8d6d7bec292c7b11ff315d9ea_2" ; -"g5.37c965a8d6d7bec292c7b11ff315d9ea_7" [label="7: Call _fun_printf \n n$3=_fun_printf((char const *)\"A\\n\":char const *) [line 114, column 3]\n EXIT_SCOPE(n$3); [line 114, column 3]\n " shape="box"] +"g5.37c965a8d6d7bec292c7b11ff315d9ea_7" [label="7: Call _fun_printf \n n$3=_fun_printf(\"A\\n\":char*) [line 114, column 3]\n EXIT_SCOPE(n$3); [line 114, column 3]\n " shape="box"] "g5.37c965a8d6d7bec292c7b11ff315d9ea_7" -> "g5.37c965a8d6d7bec292c7b11ff315d9ea_6" ; @@ -468,7 +468,7 @@ digraph cfg { "g5.37c965a8d6d7bec292c7b11ff315d9ea_21" -> "g5.37c965a8d6d7bec292c7b11ff315d9ea_18" ; -"g5.37c965a8d6d7bec292c7b11ff315d9ea_22" [label="22: Call _fun_printf \n n$18=_fun_printf((char const *)\"B\\n\":char const *) [line 102, column 3]\n EXIT_SCOPE(n$18); [line 102, column 3]\n " shape="box"] +"g5.37c965a8d6d7bec292c7b11ff315d9ea_22" [label="22: Call _fun_printf \n n$18=_fun_printf(\"B\\n\":char*) [line 102, column 3]\n EXIT_SCOPE(n$18); [line 102, column 3]\n " shape="box"] "g5.37c965a8d6d7bec292c7b11ff315d9ea_22" -> "g5.37c965a8d6d7bec292c7b11ff315d9ea_19" ; @@ -483,7 +483,7 @@ digraph cfg { "g6.4a4314ef967aad20a9e7c423bc16e39c_3" -> "g6.4a4314ef967aad20a9e7c423bc16e39c_8" ; -"g6.4a4314ef967aad20a9e7c423bc16e39c_4" [label="4: Call _fun_printf \n n$1=_fun_printf((char const *)\"exit\\n\":char const *) [line 140, column 3]\n EXIT_SCOPE(n$1); [line 140, column 3]\n APPLY_ABSTRACTION; [line 140, column 3]\n " shape="box"] +"g6.4a4314ef967aad20a9e7c423bc16e39c_4" [label="4: Call _fun_printf \n n$1=_fun_printf(\"exit\\n\":char*) [line 140, column 3]\n EXIT_SCOPE(n$1); [line 140, column 3]\n APPLY_ABSTRACTION; [line 140, column 3]\n " shape="box"] "g6.4a4314ef967aad20a9e7c423bc16e39c_4" -> "g6.4a4314ef967aad20a9e7c423bc16e39c_3" ; @@ -495,7 +495,7 @@ digraph cfg { "g6.4a4314ef967aad20a9e7c423bc16e39c_6" -> "g6.4a4314ef967aad20a9e7c423bc16e39c_2" ; -"g6.4a4314ef967aad20a9e7c423bc16e39c_7" [label="7: Call _fun_printf \n n$3=_fun_printf((char const *)\"A\\n\":char const *) [line 136, column 3]\n EXIT_SCOPE(n$3); [line 136, column 3]\n " shape="box"] +"g6.4a4314ef967aad20a9e7c423bc16e39c_7" [label="7: Call _fun_printf \n n$3=_fun_printf(\"A\\n\":char*) [line 136, column 3]\n EXIT_SCOPE(n$3); [line 136, column 3]\n " shape="box"] "g6.4a4314ef967aad20a9e7c423bc16e39c_7" -> "g6.4a4314ef967aad20a9e7c423bc16e39c_6" ; @@ -558,7 +558,7 @@ digraph cfg { "g6.4a4314ef967aad20a9e7c423bc16e39c_21" -> "g6.4a4314ef967aad20a9e7c423bc16e39c_18" ; -"g6.4a4314ef967aad20a9e7c423bc16e39c_22" [label="22: Call _fun_printf \n n$18=_fun_printf((char const *)\"B\\n\":char const *) [line 124, column 3]\n EXIT_SCOPE(n$18); [line 124, column 3]\n " shape="box"] +"g6.4a4314ef967aad20a9e7c423bc16e39c_22" [label="22: Call _fun_printf \n n$18=_fun_printf(\"B\\n\":char*) [line 124, column 3]\n EXIT_SCOPE(n$18); [line 124, column 3]\n " shape="box"] "g6.4a4314ef967aad20a9e7c423bc16e39c_22" -> "g6.4a4314ef967aad20a9e7c423bc16e39c_19" ; @@ -573,7 +573,7 @@ digraph cfg { "g7.727bb92f57c3951d11695a52c92c2b0c_3" -> "g7.727bb92f57c3951d11695a52c92c2b0c_2" ; -"g7.727bb92f57c3951d11695a52c92c2b0c_4" [label="4: Call _fun_printf \n n$0=_fun_printf((char const *)\"terminating!\\n\":char const *) [line 163, column 3]\n EXIT_SCOPE(n$0); [line 163, column 3]\n " shape="box"] +"g7.727bb92f57c3951d11695a52c92c2b0c_4" [label="4: Call _fun_printf \n n$0=_fun_printf(\"terminating!\\n\":char*) [line 163, column 3]\n EXIT_SCOPE(n$0); [line 163, column 3]\n " shape="box"] "g7.727bb92f57c3951d11695a52c92c2b0c_4" -> "g7.727bb92f57c3951d11695a52c92c2b0c_3" ; @@ -585,7 +585,7 @@ digraph cfg { "g7.727bb92f57c3951d11695a52c92c2b0c_6" -> "g7.727bb92f57c3951d11695a52c92c2b0c_25" ; -"g7.727bb92f57c3951d11695a52c92c2b0c_7" [label="7: Call _fun_printf \n n$3=_fun_printf((char const *)\"out!\\n\":char const *) [line 160, column 3]\n EXIT_SCOPE(n$3); [line 160, column 3]\n " shape="box"] +"g7.727bb92f57c3951d11695a52c92c2b0c_7" [label="7: Call _fun_printf \n n$3=_fun_printf(\"out!\\n\":char*) [line 160, column 3]\n EXIT_SCOPE(n$3); [line 160, column 3]\n " shape="box"] "g7.727bb92f57c3951d11695a52c92c2b0c_7" -> "g7.727bb92f57c3951d11695a52c92c2b0c_6" ; @@ -661,7 +661,7 @@ digraph cfg { "g7.727bb92f57c3951d11695a52c92c2b0c_24" -> "g7.727bb92f57c3951d11695a52c92c2b0c_21" ; -"g7.727bb92f57c3951d11695a52c92c2b0c_25" [label="25: Call _fun_printf \n n$10=_fun_printf((char const *)\"wow\\n\":char const *) [line 153, column 11]\n EXIT_SCOPE(n$10); [line 153, column 11]\n " shape="box"] +"g7.727bb92f57c3951d11695a52c92c2b0c_25" [label="25: Call _fun_printf \n n$10=_fun_printf(\"wow\\n\":char*) [line 153, column 11]\n EXIT_SCOPE(n$10); [line 153, column 11]\n " shape="box"] "g7.727bb92f57c3951d11695a52c92c2b0c_25" -> "g7.727bb92f57c3951d11695a52c92c2b0c_5" ; @@ -692,7 +692,7 @@ digraph cfg { "g8.c98b82371573afc08575815d90f5eac4_3" -> "g8.c98b82371573afc08575815d90f5eac4_2" ; -"g8.c98b82371573afc08575815d90f5eac4_4" [label="4: Call _fun_printf \n n$0=_fun_printf((char const *)\"terminating!\\n\":char const *) [line 186, column 3]\n EXIT_SCOPE(n$0); [line 186, column 3]\n " shape="box"] +"g8.c98b82371573afc08575815d90f5eac4_4" [label="4: Call _fun_printf \n n$0=_fun_printf(\"terminating!\\n\":char*) [line 186, column 3]\n EXIT_SCOPE(n$0); [line 186, column 3]\n " shape="box"] "g8.c98b82371573afc08575815d90f5eac4_4" -> "g8.c98b82371573afc08575815d90f5eac4_3" ; @@ -700,7 +700,7 @@ digraph cfg { "g8.c98b82371573afc08575815d90f5eac4_5" -> "g8.c98b82371573afc08575815d90f5eac4_4" ; -"g8.c98b82371573afc08575815d90f5eac4_6" [label="6: Call _fun_printf \n n$2=_fun_printf((char const *)\"out!\\n\":char const *) [line 184, column 3]\n EXIT_SCOPE(n$2); [line 184, column 3]\n " shape="box"] +"g8.c98b82371573afc08575815d90f5eac4_6" [label="6: Call _fun_printf \n n$2=_fun_printf(\"out!\\n\":char*) [line 184, column 3]\n EXIT_SCOPE(n$2); [line 184, column 3]\n " shape="box"] "g8.c98b82371573afc08575815d90f5eac4_6" -> "g8.c98b82371573afc08575815d90f5eac4_5" ; @@ -776,7 +776,7 @@ digraph cfg { "g8.c98b82371573afc08575815d90f5eac4_23" -> "g8.c98b82371573afc08575815d90f5eac4_20" ; -"g8.c98b82371573afc08575815d90f5eac4_24" [label="24: Call _fun_printf \n n$8=_fun_printf((char const *)\"wow\\n\":char const *) [line 177, column 11]\n EXIT_SCOPE(n$8); [line 177, column 11]\n APPLY_ABSTRACTION; [line 177, column 11]\n " shape="box"] +"g8.c98b82371573afc08575815d90f5eac4_24" [label="24: Call _fun_printf \n n$8=_fun_printf(\"wow\\n\":char*) [line 177, column 11]\n EXIT_SCOPE(n$8); [line 177, column 11]\n APPLY_ABSTRACTION; [line 177, column 11]\n " shape="box"] "g8.c98b82371573afc08575815d90f5eac4_24" -> "g8.c98b82371573afc08575815d90f5eac4_20" ; diff --git a/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c b/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c index 651d91172..77c4d736a 100644 --- a/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c +++ b/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c @@ -193,3 +193,18 @@ int test_switch11() { } return 0; } + +int switch_gnu_range(char c) { + int i; + switch (c) { + case 'a' ... 'f': + return 0; + break; + case '0' ... /* some long comment to make the end of the range on the next + line */ + '9': + i = atoi(c); + break; + } + return i; +} diff --git a/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c.dot b/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c.dot index 4257947bf..2eabf2de5 100644 --- a/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c.dot @@ -11,6 +11,47 @@ digraph cfg { "getValue.faa0c7b1433b0c97fcdc15fa47c8180f_3" -> "getValue.faa0c7b1433b0c97fcdc15fa47c8180f_2" ; +"switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_1" [label="1: Start switch_gnu_range\nFormals: c:char\nLocals: i:int \n " color=yellow style=filled] + + + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_1" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_4" ; +"switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_2" [label="2: Exit switch_gnu_range \n " color=yellow style=filled] + + +"switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_3" [label="3: Return Stmt \n n$0=*&i:int [line 209, column 10]\n *&return:int=n$0 [line 209, column 3]\n NULLIFY(&i); [line 209, column 3]\n EXIT_SCOPE(n$0,i); [line 209, column 3]\n APPLY_ABSTRACTION; [line 209, column 3]\n " shape="box"] + + + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_3" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_2" ; +"switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_4" [label="4: SwitchStmt \n n$1=*&c:char [line 199, column 11]\n " shape="box"] + + + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_4" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_9" ; + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_4" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_10" ; +"switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_5" [label="5: BinaryOperatorStmt: Assign \n n$3=*&c:char [line 206, column 16]\n n$4=_fun_atoi(n$3:int) [line 206, column 11]\n *&i:int=n$4 [line 206, column 7]\n NULLIFY(&c); [line 206, column 7]\n EXIT_SCOPE(n$3,n$4,c); [line 206, column 7]\n APPLY_ABSTRACTION; [line 206, column 7]\n " shape="box"] + + + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_5" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_3" ; +"switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_6" [label="6: Return Stmt \n *&return:int=0 [line 201, column 7]\n APPLY_ABSTRACTION; [line 201, column 7]\n " shape="box"] + + + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_6" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_2" ; +"switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_7" [label="7: Prune (true branch, switch) \n PRUNE((n$1 == 48), true); [line 203, column 5]\n EXIT_SCOPE(n$1); [line 203, column 5]\n " shape="invhouse"] + + + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_7" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_5" ; +"switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_8" [label="8: Prune (false branch, switch) \n PRUNE(!(n$1 == 48), false); [line 203, column 5]\n EXIT_SCOPE(n$1); [line 203, column 5]\n APPLY_ABSTRACTION; [line 203, column 5]\n " shape="invhouse"] + + + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_8" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_3" ; +"switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_9" [label="9: Prune (true branch, switch) \n PRUNE((n$1 == 97), true); [line 200, column 5]\n EXIT_SCOPE(n$1); [line 200, column 5]\n " shape="invhouse"] + + + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_9" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_6" ; +"switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_10" [label="10: Prune (false branch, switch) \n PRUNE(!(n$1 == 97), false); [line 200, column 5]\n " shape="invhouse"] + + + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_10" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_7" ; + "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_10" -> "switch_gnu_range.fe09b2428ff32c71bce6cc22d05f5102_8" ; "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_1" [label="1: Start test_switch1\nFormals: \nLocals: x:int value:int \n " color=yellow style=filled] @@ -39,7 +80,7 @@ digraph cfg { "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_7" -> "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_3" ; -"test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_8" [label="8: Call _fun_printf \n n$1=_fun_printf((char const *)\"(after_switch)HELLO WORLD!\":char const *) [line 31, column 5]\n EXIT_SCOPE(n$1); [line 31, column 5]\n APPLY_ABSTRACTION; [line 31, column 5]\n " shape="box"] +"test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_8" [label="8: Call _fun_printf \n n$1=_fun_printf(\"(after_switch)HELLO WORLD!\":char*) [line 31, column 5]\n EXIT_SCOPE(n$1); [line 31, column 5]\n APPLY_ABSTRACTION; [line 31, column 5]\n " shape="box"] "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_8" -> "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_4" ; @@ -48,15 +89,15 @@ digraph cfg { "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_9" -> "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_20" ; "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_9" -> "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_21" ; -"test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_10" [label="10: Call _fun_printf \n n$4=_fun_printf((char const *)\"(2/def)HELLO WORLD!\":char const *) [line 28, column 9]\n EXIT_SCOPE(n$4); [line 28, column 9]\n APPLY_ABSTRACTION; [line 28, column 9]\n " shape="box"] +"test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_10" [label="10: Call _fun_printf \n n$4=_fun_printf(\"(2/def)HELLO WORLD!\":char*) [line 28, column 9]\n EXIT_SCOPE(n$4); [line 28, column 9]\n APPLY_ABSTRACTION; [line 28, column 9]\n " shape="box"] "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_10" -> "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_4" ; -"test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_11" [label="11: Call _fun_printf \n n$6=_fun_printf((char const *)\"(1)HELLO WORLD!\":char const *) [line 24, column 9]\n EXIT_SCOPE(n$6); [line 24, column 9]\n APPLY_ABSTRACTION; [line 24, column 9]\n " shape="box"] +"test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_11" [label="11: Call _fun_printf \n n$6=_fun_printf(\"(1)HELLO WORLD!\":char*) [line 24, column 9]\n EXIT_SCOPE(n$6); [line 24, column 9]\n APPLY_ABSTRACTION; [line 24, column 9]\n " shape="box"] "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_11" -> "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_4" ; -"test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_12" [label="12: Call _fun_printf \n n$8=_fun_printf((char const *)\"(0)HELLO WORLD!\":char const *) [line 21, column 9]\n EXIT_SCOPE(n$8); [line 21, column 9]\n " shape="box"] +"test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_12" [label="12: Call _fun_printf \n n$8=_fun_printf(\"(0)HELLO WORLD!\":char*) [line 21, column 9]\n EXIT_SCOPE(n$8); [line 21, column 9]\n " shape="box"] "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_12" -> "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_8" ; @@ -64,7 +105,7 @@ digraph cfg { "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_13" -> "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_12" ; -"test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_14" [label="14: Call _fun_printf \n n$10=_fun_printf((char const *)\"(out)HELLO WORLD!\":char const *) [line 18, column 7]\n " shape="box"] +"test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_14" [label="14: Call _fun_printf \n n$10=_fun_printf(\"(out)HELLO WORLD!\":char*) [line 18, column 7]\n " shape="box"] "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_14" -> "test_switch1.7c92c7e14d1a0ee28a9ab29b22df5d3f_13" ; @@ -162,7 +203,7 @@ digraph cfg { "test_switch11.a1a6d859e414d268a57ed2a2bb6f8a8e_10" -> "test_switch11.a1a6d859e414d268a57ed2a2bb6f8a8e_12" ; "test_switch11.a1a6d859e414d268a57ed2a2bb6f8a8e_10" -> "test_switch11.a1a6d859e414d268a57ed2a2bb6f8a8e_13" ; -"test_switch11.a1a6d859e414d268a57ed2a2bb6f8a8e_11" [label="11: Call _fun_printf \n n$4=_fun_printf((char const *)\"(0)HELLO WORLD!\":char const *) [line 192, column 7]\n EXIT_SCOPE(n$4); [line 192, column 7]\n APPLY_ABSTRACTION; [line 192, column 7]\n " shape="box"] +"test_switch11.a1a6d859e414d268a57ed2a2bb6f8a8e_11" [label="11: Call _fun_printf \n n$4=_fun_printf(\"(0)HELLO WORLD!\":char*) [line 192, column 7]\n EXIT_SCOPE(n$4); [line 192, column 7]\n APPLY_ABSTRACTION; [line 192, column 7]\n " shape="box"] "test_switch11.a1a6d859e414d268a57ed2a2bb6f8a8e_11" -> "test_switch11.a1a6d859e414d268a57ed2a2bb6f8a8e_3" ; @@ -210,7 +251,7 @@ digraph cfg { "test_switch2.0717c55583f10f472ddb2d73d867e556_8" -> "test_switch2.0717c55583f10f472ddb2d73d867e556_7" ; -"test_switch2.0717c55583f10f472ddb2d73d867e556_9" [label="9: Call _fun_printf \n n$5=_fun_printf((char const *)\"(0)HELLO WORLD!\":char const *) [line 41, column 7]\n EXIT_SCOPE(n$5); [line 41, column 7]\n APPLY_ABSTRACTION; [line 41, column 7]\n " shape="box"] +"test_switch2.0717c55583f10f472ddb2d73d867e556_9" [label="9: Call _fun_printf \n n$5=_fun_printf(\"(0)HELLO WORLD!\":char*) [line 41, column 7]\n EXIT_SCOPE(n$5); [line 41, column 7]\n APPLY_ABSTRACTION; [line 41, column 7]\n " shape="box"] "test_switch2.0717c55583f10f472ddb2d73d867e556_9" -> "test_switch2.0717c55583f10f472ddb2d73d867e556_3" ; @@ -280,7 +321,7 @@ digraph cfg { "test_switch3.d602e3f7cc0068667fd33a3e54ff193c_7" -> "test_switch3.d602e3f7cc0068667fd33a3e54ff193c_6" ; -"test_switch3.d602e3f7cc0068667fd33a3e54ff193c_8" [label="8: Call _fun_printf \n n$5=_fun_printf((char const *)\"(0)HELLO WORLD!\":char const *) [line 63, column 7]\n EXIT_SCOPE(n$5); [line 63, column 7]\n APPLY_ABSTRACTION; [line 63, column 7]\n " shape="box"] +"test_switch3.d602e3f7cc0068667fd33a3e54ff193c_8" [label="8: Call _fun_printf \n n$5=_fun_printf(\"(0)HELLO WORLD!\":char*) [line 63, column 7]\n EXIT_SCOPE(n$5); [line 63, column 7]\n APPLY_ABSTRACTION; [line 63, column 7]\n " shape="box"] "test_switch3.d602e3f7cc0068667fd33a3e54ff193c_8" -> "test_switch3.d602e3f7cc0068667fd33a3e54ff193c_3" ; @@ -355,7 +396,7 @@ digraph cfg { "test_switch4.70d4e6e8539e8d1ee3505d4562bc236d_8" -> "test_switch4.70d4e6e8539e8d1ee3505d4562bc236d_7" ; -"test_switch4.70d4e6e8539e8d1ee3505d4562bc236d_9" [label="9: Call _fun_printf \n n$5=_fun_printf((char const *)\"(0)HELLO WORLD!\":char const *) [line 82, column 7]\n EXIT_SCOPE(n$5); [line 82, column 7]\n APPLY_ABSTRACTION; [line 82, column 7]\n " shape="box"] +"test_switch4.70d4e6e8539e8d1ee3505d4562bc236d_9" [label="9: Call _fun_printf \n n$5=_fun_printf(\"(0)HELLO WORLD!\":char*) [line 82, column 7]\n EXIT_SCOPE(n$5); [line 82, column 7]\n APPLY_ABSTRACTION; [line 82, column 7]\n " shape="box"] "test_switch4.70d4e6e8539e8d1ee3505d4562bc236d_9" -> "test_switch4.70d4e6e8539e8d1ee3505d4562bc236d_3" ; @@ -430,7 +471,7 @@ digraph cfg { "test_switch5.1d93fcc376cd01517eabe22cb325bcfd_8" -> "test_switch5.1d93fcc376cd01517eabe22cb325bcfd_12" ; "test_switch5.1d93fcc376cd01517eabe22cb325bcfd_8" -> "test_switch5.1d93fcc376cd01517eabe22cb325bcfd_13" ; -"test_switch5.1d93fcc376cd01517eabe22cb325bcfd_9" [label="9: Call _fun_printf \n n$3=_fun_printf((char const *)\"(0)HELLO WORLD!\":char const *) [line 109, column 9]\n EXIT_SCOPE(n$3); [line 109, column 9]\n APPLY_ABSTRACTION; [line 109, column 9]\n " shape="box"] +"test_switch5.1d93fcc376cd01517eabe22cb325bcfd_9" [label="9: Call _fun_printf \n n$3=_fun_printf(\"(0)HELLO WORLD!\":char*) [line 109, column 9]\n EXIT_SCOPE(n$3); [line 109, column 9]\n APPLY_ABSTRACTION; [line 109, column 9]\n " shape="box"] "test_switch5.1d93fcc376cd01517eabe22cb325bcfd_9" -> "test_switch5.1d93fcc376cd01517eabe22cb325bcfd_4" ; @@ -438,7 +479,7 @@ digraph cfg { "test_switch5.1d93fcc376cd01517eabe22cb325bcfd_10" -> "test_switch5.1d93fcc376cd01517eabe22cb325bcfd_4" ; -"test_switch5.1d93fcc376cd01517eabe22cb325bcfd_11" [label="11: Call _fun_printf \n n$6=_fun_printf((char const *)\"(out)HELLO WORLD!\":char const *) [line 105, column 7]\n " shape="box"] +"test_switch5.1d93fcc376cd01517eabe22cb325bcfd_11" [label="11: Call _fun_printf \n n$6=_fun_printf(\"(out)HELLO WORLD!\":char*) [line 105, column 7]\n " shape="box"] "test_switch5.1d93fcc376cd01517eabe22cb325bcfd_11" -> "test_switch5.1d93fcc376cd01517eabe22cb325bcfd_10" ; @@ -507,7 +548,7 @@ digraph cfg { "test_switch6.a23e54b3840073f4ece330ef3c560915_13" -> "test_switch6.a23e54b3840073f4ece330ef3c560915_12" ; -"test_switch6.a23e54b3840073f4ece330ef3c560915_14" [label="14: Call _fun_printf \n n$7=_fun_printf((char const *)\"(0)HELLO WORLD!\":char const *) [line 120, column 7]\n EXIT_SCOPE(n$7); [line 120, column 7]\n APPLY_ABSTRACTION; [line 120, column 7]\n " shape="box"] +"test_switch6.a23e54b3840073f4ece330ef3c560915_14" [label="14: Call _fun_printf \n n$7=_fun_printf(\"(0)HELLO WORLD!\":char*) [line 120, column 7]\n EXIT_SCOPE(n$7); [line 120, column 7]\n APPLY_ABSTRACTION; [line 120, column 7]\n " shape="box"] "test_switch6.a23e54b3840073f4ece330ef3c560915_14" -> "test_switch6.a23e54b3840073f4ece330ef3c560915_3" ; @@ -578,7 +619,7 @@ digraph cfg { "test_switch7.8298274f5578f21bdddf71ffa79afcb8_7" -> "test_switch7.8298274f5578f21bdddf71ffa79afcb8_6" ; -"test_switch7.8298274f5578f21bdddf71ffa79afcb8_8" [label="8: Call _fun_printf \n n$5=_fun_printf((char const *)\"(0)HELLO WORLD!\":char const *) [line 140, column 7]\n EXIT_SCOPE(n$5); [line 140, column 7]\n APPLY_ABSTRACTION; [line 140, column 7]\n " shape="box"] +"test_switch7.8298274f5578f21bdddf71ffa79afcb8_8" [label="8: Call _fun_printf \n n$5=_fun_printf(\"(0)HELLO WORLD!\":char*) [line 140, column 7]\n EXIT_SCOPE(n$5); [line 140, column 7]\n APPLY_ABSTRACTION; [line 140, column 7]\n " shape="box"] "test_switch7.8298274f5578f21bdddf71ffa79afcb8_8" -> "test_switch7.8298274f5578f21bdddf71ffa79afcb8_3" ; @@ -699,7 +740,7 @@ digraph cfg { "test_switch8.6a6653773b94c1bb3f3c90dc1790d1ed_19" -> "test_switch8.6a6653773b94c1bb3f3c90dc1790d1ed_2" ; -"test_switch8.6a6653773b94c1bb3f3c90dc1790d1ed_20" [label="20: Call _fun_printf \n n$8=_fun_printf((char const *)\"(0)HELLO WORLD!\":char const *) [line 159, column 9]\n EXIT_SCOPE(n$8); [line 159, column 9]\n " shape="box"] +"test_switch8.6a6653773b94c1bb3f3c90dc1790d1ed_20" [label="20: Call _fun_printf \n n$8=_fun_printf(\"(0)HELLO WORLD!\":char*) [line 159, column 9]\n EXIT_SCOPE(n$8); [line 159, column 9]\n " shape="box"] "test_switch8.6a6653773b94c1bb3f3c90dc1790d1ed_20" -> "test_switch8.6a6653773b94c1bb3f3c90dc1790d1ed_19" ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/Makefile b/infer/tests/codetoanalyze/cpp/frontend/Makefile index 794da08a4..b7b78a02e 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/Makefile +++ b/infer/tests/codetoanalyze/cpp/frontend/Makefile @@ -13,6 +13,7 @@ INFER_OPTIONS = SOURCES = \ + $(wildcard *.cpp) \ $(wildcard */*.cpp) \ $(wildcard shared/*/*.cpp) \ diff --git a/infer/tests/codetoanalyze/cpp/frontend/if.cpp b/infer/tests/codetoanalyze/cpp/frontend/if.cpp new file mode 100644 index 000000000..76224336f --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/frontend/if.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +void if_then_return(int x) { + int y = 0; + if (x == 1234) { + y = x; + } +} + +void if_then(int x) { + int y = 0; + if (x == 1234) { + y = x; + } + y = 111; +} + +void if_then_else_return(int x) { + int y = 0; + if (x == 1234) { + y = 111; + } else { + y = 222; + } +} + +void if_then_else(int x) { + int y = 0; + if (x == 1234) { + y = 111; + } else { + y = 222; + } + y = 333; +} + +void if_then_cond_var() { + int y = 0; + if (int x = 4) { + y = x; + } + y = 111; +} + +void if_then_else_cond_var() { + int y = 0; + if (int x = 4) { + y = x; + } else { + y = x * 2; + } + y = 111; +} + +void if_then_init(int x) { + int y = 0; + if (int x = 4; x == 4) { + y = x; + } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/if.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/if.cpp.dot new file mode 100644 index 000000000..4da525f8b --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/frontend/if.cpp.dot @@ -0,0 +1,271 @@ +/* @generated */ +digraph cfg { +"if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_1" [label="1: Start if_then\nFormals: x:int\nLocals: y:int \n " color=yellow style=filled] + + + "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_1" -> "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_9" ; +"if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_2" [label="2: Exit if_then \n " color=yellow style=filled] + + +"if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_3" [label="3: BinaryOperatorStmt: Assign \n *&y:int=111 [line 20, column 3]\n NULLIFY(&y); [line 20, column 3]\n EXIT_SCOPE(y); [line 20, column 3]\n APPLY_ABSTRACTION; [line 20, column 3]\n " shape="box"] + + + "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_3" -> "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_2" ; +"if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_4" [label="4: + \n " ] + + + "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_4" -> "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_3" ; +"if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_5" [label="5: BinaryOperatorStmt: EQ \n n$1=*&x:int [line 17, column 7]\n " shape="box"] + + + "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_5" -> "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_6" ; + "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_5" -> "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_7" ; +"if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_6" [label="6: Prune (true branch, if) \n PRUNE((n$1 == 1234), true); [line 17, column 7]\n EXIT_SCOPE(n$1); [line 17, column 7]\n " shape="invhouse"] + + + "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_6" -> "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_8" ; +"if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_7" [label="7: Prune (false branch, if) \n PRUNE(!(n$1 == 1234), false); [line 17, column 7]\n EXIT_SCOPE(n$1); [line 17, column 7]\n APPLY_ABSTRACTION; [line 17, column 7]\n " shape="invhouse"] + + + "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_7" -> "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_4" ; +"if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_8" [label="8: BinaryOperatorStmt: Assign \n n$3=*&x:int [line 18, column 9]\n *&y:int=n$3 [line 18, column 5]\n NULLIFY(&y); [line 18, column 5]\n NULLIFY(&x); [line 18, column 5]\n EXIT_SCOPE(n$3,y,x); [line 18, column 5]\n APPLY_ABSTRACTION; [line 18, column 5]\n " shape="box"] + + + "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_8" -> "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_4" ; +"if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_9" [label="9: DeclStmt \n VARIABLE_DECLARED(y:int); [line 16, column 3]\n *&y:int=0 [line 16, column 3]\n NULLIFY(&y); [line 16, column 3]\n EXIT_SCOPE(y); [line 16, column 3]\n " shape="box"] + + + "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_9" -> "if_then#3243301102387331199.d347686d1797cf6cf5f5b9b986a1e67d_5" ; +"if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_1" [label="1: Start if_then_cond_var\nFormals: \nLocals: x:int y:int \n " color=yellow style=filled] + + + "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_1" -> "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_9" ; +"if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_2" [label="2: Exit if_then_cond_var \n " color=yellow style=filled] + + +"if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_3" [label="3: BinaryOperatorStmt: Assign \n *&y:int=111 [line 47, column 3]\n NULLIFY(&y); [line 47, column 3]\n EXIT_SCOPE(y); [line 47, column 3]\n APPLY_ABSTRACTION; [line 47, column 3]\n " shape="box"] + + + "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_3" -> "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_2" ; +"if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_4" [label="4: + \n " ] + + + "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_4" -> "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_3" ; +"if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_5" [label="5: Prune (true branch, if) \n n$1=*&x:int [line 44, column 11]\n PRUNE(n$1, true); [line 44, column 11]\n EXIT_SCOPE(n$1); [line 44, column 11]\n " shape="invhouse"] + + + "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_5" -> "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_8" ; +"if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_6" [label="6: Prune (false branch, if) \n n$1=*&x:int [line 44, column 11]\n PRUNE(!n$1, false); [line 44, column 11]\n NULLIFY(&x); [line 44, column 11]\n EXIT_SCOPE(n$1,x); [line 44, column 11]\n APPLY_ABSTRACTION; [line 44, column 11]\n " shape="invhouse"] + + + "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_6" -> "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_4" ; +"if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_7" [label="7: DeclStmt \n VARIABLE_DECLARED(x:int); [line 44, column 7]\n *&x:int=4 [line 44, column 7]\n " shape="box"] + + + "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_7" -> "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_5" ; + "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_7" -> "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_6" ; +"if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_8" [label="8: BinaryOperatorStmt: Assign \n n$3=*&x:int [line 45, column 9]\n *&y:int=n$3 [line 45, column 5]\n NULLIFY(&x); [line 45, column 5]\n NULLIFY(&y); [line 45, column 5]\n EXIT_SCOPE(n$3,x,y); [line 45, column 5]\n APPLY_ABSTRACTION; [line 45, column 5]\n " shape="box"] + + + "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_8" -> "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_4" ; +"if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_9" [label="9: DeclStmt \n VARIABLE_DECLARED(y:int); [line 43, column 3]\n *&y:int=0 [line 43, column 3]\n NULLIFY(&y); [line 43, column 3]\n EXIT_SCOPE(y); [line 43, column 3]\n " shape="box"] + + + "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_9" -> "if_then_cond_var#9765064652804376901.7ddd70d5a9df7af72d704522a5beba46_7" ; +"if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_1" [label="1: Start if_then_else\nFormals: x:int\nLocals: y:int \n " color=yellow style=filled] + + + "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_1" -> "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_10" ; +"if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_2" [label="2: Exit if_then_else \n " color=yellow style=filled] + + +"if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_3" [label="3: BinaryOperatorStmt: Assign \n *&y:int=333 [line 39, column 3]\n NULLIFY(&y); [line 39, column 3]\n EXIT_SCOPE(y); [line 39, column 3]\n APPLY_ABSTRACTION; [line 39, column 3]\n " shape="box"] + + + "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_3" -> "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_2" ; +"if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_4" [label="4: + \n " ] + + + "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_4" -> "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_3" ; +"if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_5" [label="5: BinaryOperatorStmt: EQ \n n$1=*&x:int [line 34, column 7]\n NULLIFY(&x); [line 34, column 7]\n EXIT_SCOPE(x); [line 34, column 7]\n " shape="box"] + + + "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_5" -> "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_6" ; + "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_5" -> "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_7" ; +"if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_6" [label="6: Prune (true branch, if) \n PRUNE((n$1 == 1234), true); [line 34, column 7]\n EXIT_SCOPE(n$1); [line 34, column 7]\n " shape="invhouse"] + + + "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_6" -> "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_8" ; +"if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_7" [label="7: Prune (false branch, if) \n PRUNE(!(n$1 == 1234), false); [line 34, column 7]\n EXIT_SCOPE(n$1); [line 34, column 7]\n " shape="invhouse"] + + + "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_7" -> "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_9" ; +"if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_8" [label="8: BinaryOperatorStmt: Assign \n *&y:int=111 [line 35, column 5]\n NULLIFY(&y); [line 35, column 5]\n EXIT_SCOPE(y); [line 35, column 5]\n APPLY_ABSTRACTION; [line 35, column 5]\n " shape="box"] + + + "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_8" -> "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_4" ; +"if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_9" [label="9: BinaryOperatorStmt: Assign \n *&y:int=222 [line 37, column 5]\n NULLIFY(&y); [line 37, column 5]\n EXIT_SCOPE(y); [line 37, column 5]\n APPLY_ABSTRACTION; [line 37, column 5]\n " shape="box"] + + + "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_9" -> "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_4" ; +"if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_10" [label="10: DeclStmt \n VARIABLE_DECLARED(y:int); [line 33, column 3]\n *&y:int=0 [line 33, column 3]\n NULLIFY(&y); [line 33, column 3]\n EXIT_SCOPE(y); [line 33, column 3]\n " shape="box"] + + + "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_10" -> "if_then_else#3656205175867614205.85ec2e9f625ee4f71821f6eee2969089_5" ; +"if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_1" [label="1: Start if_then_else_cond_var\nFormals: \nLocals: x:int y:int \n " color=yellow style=filled] + + + "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_1" -> "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_10" ; +"if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_2" [label="2: Exit if_then_else_cond_var \n " color=yellow style=filled] + + +"if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_3" [label="3: BinaryOperatorStmt: Assign \n *&y:int=111 [line 57, column 3]\n NULLIFY(&y); [line 57, column 3]\n EXIT_SCOPE(y); [line 57, column 3]\n APPLY_ABSTRACTION; [line 57, column 3]\n " shape="box"] + + + "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_3" -> "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_2" ; +"if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_4" [label="4: + \n " ] + + + "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_4" -> "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_3" ; +"if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_5" [label="5: Prune (true branch, if) \n n$1=*&x:int [line 52, column 11]\n PRUNE(n$1, true); [line 52, column 11]\n EXIT_SCOPE(n$1); [line 52, column 11]\n " shape="invhouse"] + + + "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_5" -> "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_8" ; +"if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_6" [label="6: Prune (false branch, if) \n n$1=*&x:int [line 52, column 11]\n PRUNE(!n$1, false); [line 52, column 11]\n EXIT_SCOPE(n$1); [line 52, column 11]\n " shape="invhouse"] + + + "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_6" -> "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_9" ; +"if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_7" [label="7: DeclStmt \n VARIABLE_DECLARED(x:int); [line 52, column 7]\n *&x:int=4 [line 52, column 7]\n " shape="box"] + + + "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_7" -> "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_5" ; + "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_7" -> "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_6" ; +"if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_8" [label="8: BinaryOperatorStmt: Assign \n n$3=*&x:int [line 53, column 9]\n *&y:int=n$3 [line 53, column 5]\n NULLIFY(&x); [line 53, column 5]\n NULLIFY(&y); [line 53, column 5]\n EXIT_SCOPE(n$3,x,y); [line 53, column 5]\n APPLY_ABSTRACTION; [line 53, column 5]\n " shape="box"] + + + "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_8" -> "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_4" ; +"if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_9" [label="9: BinaryOperatorStmt: Assign \n n$5=*&x:int [line 55, column 9]\n *&y:int=(n$5 * 2) [line 55, column 5]\n NULLIFY(&x); [line 55, column 5]\n NULLIFY(&y); [line 55, column 5]\n EXIT_SCOPE(n$5,x,y); [line 55, column 5]\n APPLY_ABSTRACTION; [line 55, column 5]\n " shape="box"] + + + "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_9" -> "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_4" ; +"if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_10" [label="10: DeclStmt \n VARIABLE_DECLARED(y:int); [line 51, column 3]\n *&y:int=0 [line 51, column 3]\n NULLIFY(&y); [line 51, column 3]\n EXIT_SCOPE(y); [line 51, column 3]\n " shape="box"] + + + "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_10" -> "if_then_else_cond_var#2787713781872682235.ef4601af9985bcc4fc7e24bbd9a44d0f_7" ; +"if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_1" [label="1: Start if_then_else_return\nFormals: x:int\nLocals: y:int \n " color=yellow style=filled] + + + "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_1" -> "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_10" ; +"if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_2" [label="2: Exit if_then_else_return \n " color=yellow style=filled] + + +"if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_3" [label="3: + \n " ] + + + "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_3" -> "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_4" ; +"if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_4" [label="4: between_join_and_exit \n APPLY_ABSTRACTION; [line 25, column 3]\n " shape="box"] + + + "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_4" -> "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_2" ; +"if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_5" [label="5: BinaryOperatorStmt: EQ \n n$1=*&x:int [line 25, column 7]\n NULLIFY(&x); [line 25, column 7]\n EXIT_SCOPE(x); [line 25, column 7]\n " shape="box"] + + + "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_5" -> "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_6" ; + "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_5" -> "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_7" ; +"if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_6" [label="6: Prune (true branch, if) \n PRUNE((n$1 == 1234), true); [line 25, column 7]\n EXIT_SCOPE(n$1); [line 25, column 7]\n " shape="invhouse"] + + + "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_6" -> "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_8" ; +"if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_7" [label="7: Prune (false branch, if) \n PRUNE(!(n$1 == 1234), false); [line 25, column 7]\n EXIT_SCOPE(n$1); [line 25, column 7]\n " shape="invhouse"] + + + "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_7" -> "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_9" ; +"if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_8" [label="8: BinaryOperatorStmt: Assign \n *&y:int=111 [line 26, column 5]\n NULLIFY(&y); [line 26, column 5]\n EXIT_SCOPE(y); [line 26, column 5]\n APPLY_ABSTRACTION; [line 26, column 5]\n " shape="box"] + + + "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_8" -> "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_3" ; +"if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_9" [label="9: BinaryOperatorStmt: Assign \n *&y:int=222 [line 28, column 5]\n NULLIFY(&y); [line 28, column 5]\n EXIT_SCOPE(y); [line 28, column 5]\n APPLY_ABSTRACTION; [line 28, column 5]\n " shape="box"] + + + "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_9" -> "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_3" ; +"if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_10" [label="10: DeclStmt \n VARIABLE_DECLARED(y:int); [line 24, column 3]\n *&y:int=0 [line 24, column 3]\n NULLIFY(&y); [line 24, column 3]\n EXIT_SCOPE(y); [line 24, column 3]\n " shape="box"] + + + "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_10" -> "if_then_else_return#4431567770337235941.d66facc967fa3d7bd91a335f2fa44d33_5" ; +"if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_1" [label="1: Start if_then_init\nFormals: x:int\nLocals: x:int y:int \n " color=yellow style=filled] + + + "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_1" -> "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_10" ; +"if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_2" [label="2: Exit if_then_init \n " color=yellow style=filled] + + +"if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_3" [label="3: + \n " ] + + + "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_3" -> "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_4" ; +"if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_4" [label="4: between_join_and_exit \n APPLY_ABSTRACTION; [line 62, column 3]\n " shape="box"] + + + "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_4" -> "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_2" ; +"if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_5" [label="5: BinaryOperatorStmt: EQ \n n$1=*&x:int [line 62, column 18]\n " shape="box"] + + + "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_5" -> "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_6" ; + "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_5" -> "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_7" ; +"if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_6" [label="6: Prune (true branch, if) \n PRUNE((n$1 == 4), true); [line 62, column 18]\n EXIT_SCOPE(n$1); [line 62, column 18]\n " shape="invhouse"] + + + "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_6" -> "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_8" ; +"if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_7" [label="7: Prune (false branch, if) \n PRUNE(!(n$1 == 4), false); [line 62, column 18]\n NULLIFY(&x); [line 62, column 18]\n EXIT_SCOPE(n$1,x); [line 62, column 18]\n APPLY_ABSTRACTION; [line 62, column 18]\n " shape="invhouse"] + + + "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_7" -> "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_3" ; +"if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_8" [label="8: BinaryOperatorStmt: Assign \n n$3=*&x:int [line 63, column 9]\n *&y:int=n$3 [line 63, column 5]\n NULLIFY(&x); [line 63, column 5]\n NULLIFY(&y); [line 63, column 5]\n EXIT_SCOPE(n$3,x,y); [line 63, column 5]\n APPLY_ABSTRACTION; [line 63, column 5]\n " shape="box"] + + + "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_8" -> "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_3" ; +"if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_9" [label="9: DeclStmt \n VARIABLE_DECLARED(x:int); [line 62, column 7]\n *&x:int=4 [line 62, column 7]\n " shape="box"] + + + "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_9" -> "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_5" ; +"if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_10" [label="10: DeclStmt \n VARIABLE_DECLARED(y:int); [line 61, column 3]\n *&y:int=0 [line 61, column 3]\n NULLIFY(&y); [line 61, column 3]\n EXIT_SCOPE(y); [line 61, column 3]\n " shape="box"] + + + "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_10" -> "if_then_init#11608825163312327704.a731baaac66bccf9a8e7312d2dc99b5f_9" ; +"if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_1" [label="1: Start if_then_return\nFormals: x:int\nLocals: y:int \n " color=yellow style=filled] + + + "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_1" -> "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_9" ; +"if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_2" [label="2: Exit if_then_return \n " color=yellow style=filled] + + +"if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_3" [label="3: + \n " ] + + + "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_3" -> "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_4" ; +"if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_4" [label="4: between_join_and_exit \n APPLY_ABSTRACTION; [line 10, column 3]\n " shape="box"] + + + "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_4" -> "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_2" ; +"if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_5" [label="5: BinaryOperatorStmt: EQ \n n$1=*&x:int [line 10, column 7]\n " shape="box"] + + + "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_5" -> "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_6" ; + "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_5" -> "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_7" ; +"if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_6" [label="6: Prune (true branch, if) \n PRUNE((n$1 == 1234), true); [line 10, column 7]\n EXIT_SCOPE(n$1); [line 10, column 7]\n " shape="invhouse"] + + + "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_6" -> "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_8" ; +"if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_7" [label="7: Prune (false branch, if) \n PRUNE(!(n$1 == 1234), false); [line 10, column 7]\n EXIT_SCOPE(n$1); [line 10, column 7]\n APPLY_ABSTRACTION; [line 10, column 7]\n " shape="invhouse"] + + + "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_7" -> "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_3" ; +"if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_8" [label="8: BinaryOperatorStmt: Assign \n n$3=*&x:int [line 11, column 9]\n *&y:int=n$3 [line 11, column 5]\n NULLIFY(&y); [line 11, column 5]\n NULLIFY(&x); [line 11, column 5]\n EXIT_SCOPE(n$3,y,x); [line 11, column 5]\n APPLY_ABSTRACTION; [line 11, column 5]\n " shape="box"] + + + "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_8" -> "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_3" ; +"if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_9" [label="9: DeclStmt \n VARIABLE_DECLARED(y:int); [line 9, column 3]\n *&y:int=0 [line 9, column 3]\n NULLIFY(&y); [line 9, column 3]\n EXIT_SCOPE(y); [line 9, column 3]\n " shape="box"] + + + "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_9" -> "if_then_return#7560400730320632534.710a386e6459fee25726e9e12804127e_5" ; +} diff --git a/infer/tests/codetoanalyze/cpp/shared/methods/byvals.cpp.dot b/infer/tests/codetoanalyze/cpp/shared/methods/byvals.cpp.dot index a599b3a65..869519f8c 100644 --- a/infer/tests/codetoanalyze/cpp/shared/methods/byvals.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/shared/methods/byvals.cpp.dot @@ -62,7 +62,7 @@ digraph cfg { "forward#std#5548362574050729124.664bf3a19e8401f31df778b67554bdae_2" [label="2: Exit std::forward \n " color=yellow style=filled] -"forward#std#5548362574050729124.664bf3a19e8401f31df778b67554bdae_3" [label="3: Return Stmt \n n$0=*&__t:int& [line 2305, column 31]\n *&return:int&=n$0 [line 2305, column 5]\n NULLIFY(&__t); [line 2305, column 5]\n EXIT_SCOPE(n$0,__t); [line 2305, column 5]\n APPLY_ABSTRACTION; [line 2305, column 5]\n " shape="box"] +"forward#std#5548362574050729124.664bf3a19e8401f31df778b67554bdae_3" [label="3: Return Stmt \n n$0=*&__t:int& [line 2313, column 31]\n *&return:int&=n$0 [line 2313, column 5]\n NULLIFY(&__t); [line 2313, column 5]\n EXIT_SCOPE(n$0,__t); [line 2313, column 5]\n APPLY_ABSTRACTION; [line 2313, column 5]\n " shape="box"] "forward#std#5548362574050729124.664bf3a19e8401f31df778b67554bdae_3" -> "forward#std#5548362574050729124.664bf3a19e8401f31df778b67554bdae_2" ; @@ -73,7 +73,7 @@ digraph cfg { "forward#std#2714018779968350623.5a6c534312c02b38db42a98e7dfe7983_2" [label="2: Exit std::forward \n " color=yellow style=filled] -"forward#std#2714018779968350623.5a6c534312c02b38db42a98e7dfe7983_3" [label="3: Return Stmt \n n$0=*&__t:int& [line 2305, column 31]\n *&return:int&=n$0 [line 2305, column 5]\n NULLIFY(&__t); [line 2305, column 5]\n EXIT_SCOPE(n$0,__t); [line 2305, column 5]\n APPLY_ABSTRACTION; [line 2305, column 5]\n " shape="box"] +"forward#std#2714018779968350623.5a6c534312c02b38db42a98e7dfe7983_3" [label="3: Return Stmt \n n$0=*&__t:int& [line 2313, column 31]\n *&return:int&=n$0 [line 2313, column 5]\n NULLIFY(&__t); [line 2313, column 5]\n EXIT_SCOPE(n$0,__t); [line 2313, column 5]\n APPLY_ABSTRACTION; [line 2313, column 5]\n " shape="box"] "forward#std#2714018779968350623.5a6c534312c02b38db42a98e7dfe7983_3" -> "forward#std#2714018779968350623.5a6c534312c02b38db42a98e7dfe7983_2" ; diff --git a/infer/tests/codetoanalyze/objc/frontend/block/static.m.dot b/infer/tests/codetoanalyze/objc/frontend/block/static.m.dot index 01929271b..8cc0ec931 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/static.m.dot +++ b/infer/tests/codetoanalyze/objc/frontend/block/static.m.dot @@ -40,7 +40,7 @@ digraph cfg { "objc_blockA::test_1.2002c886c49fdecdc4bf7a72fba954ba_2" [label="2: Exit objc_blockA::test_1 \n " color=yellow style=filled] -"objc_blockA::test_1.2002c886c49fdecdc4bf7a72fba954ba_3" [label="3: BinaryOperatorStmt: Assign \n n$1=_fun___objc_alloc_no_fail(sizeof(t=A):unsigned long) [line 19, column 23]\n n$2=_fun_NSBundleResourceRequest::init(n$1:A*) virtual [line 19, column 22]\n *&#GB$A::test.sharedInstance:objc_object*=n$2 [line 19, column 5]\n EXIT_SCOPE(n$1,n$2); [line 19, column 5]\n APPLY_ABSTRACTION; [line 19, column 5]\n " shape="box"] +"objc_blockA::test_1.2002c886c49fdecdc4bf7a72fba954ba_3" [label="3: BinaryOperatorStmt: Assign \n n$1=_fun___objc_alloc_no_fail(sizeof(t=A):unsigned long) [line 19, column 23]\n n$2=_fun_NSObject::init(n$1:A*) virtual [line 19, column 22]\n *&#GB$A::test.sharedInstance:objc_object*=n$2 [line 19, column 5]\n EXIT_SCOPE(n$1,n$2); [line 19, column 5]\n APPLY_ABSTRACTION; [line 19, column 5]\n " shape="box"] "objc_blockA::test_1.2002c886c49fdecdc4bf7a72fba954ba_3" -> "objc_blockA::test_1.2002c886c49fdecdc4bf7a72fba954ba_2" ; @@ -51,7 +51,7 @@ digraph cfg { "objc_blockA::test_leak_2.5f4f71e062f7fac0ae4a5b163d676189_2" [label="2: Exit objc_blockA::test_leak_2 \n " color=yellow style=filled] -"objc_blockA::test_leak_2.5f4f71e062f7fac0ae4a5b163d676189_3" [label="3: BinaryOperatorStmt: Assign \n n$4=_fun___objc_alloc_no_fail(sizeof(t=A):unsigned long) [line 29, column 23]\n n$5=_fun_NSBundleResourceRequest::init(n$4:A*) virtual [line 29, column 22]\n *&#GB$A::test_leak.sharedInstance:objc_object*=n$5 [line 29, column 5]\n EXIT_SCOPE(n$4,n$5); [line 29, column 5]\n APPLY_ABSTRACTION; [line 29, column 5]\n " shape="box"] +"objc_blockA::test_leak_2.5f4f71e062f7fac0ae4a5b163d676189_3" [label="3: BinaryOperatorStmt: Assign \n n$4=_fun___objc_alloc_no_fail(sizeof(t=A):unsigned long) [line 29, column 23]\n n$5=_fun_NSObject::init(n$4:A*) virtual [line 29, column 22]\n *&#GB$A::test_leak.sharedInstance:objc_object*=n$5 [line 29, column 5]\n EXIT_SCOPE(n$4,n$5); [line 29, column 5]\n APPLY_ABSTRACTION; [line 29, column 5]\n " shape="box"] "objc_blockA::test_leak_2.5f4f71e062f7fac0ae4a5b163d676189_3" -> "objc_blockA::test_leak_2.5f4f71e062f7fac0ae4a5b163d676189_2" ; @@ -85,7 +85,7 @@ digraph cfg { "test2#A#class.ce50cb13c3345decc567dd4eb6124604_4" -> "test2#A#class.ce50cb13c3345decc567dd4eb6124604_3" ; -"test2#A#class.ce50cb13c3345decc567dd4eb6124604_5" [label="5: BinaryOperatorStmt: Assign \n n$10=_fun___objc_alloc_no_fail(sizeof(t=A):unsigned long) [line 36, column 21]\n n$11=_fun_NSBundleResourceRequest::init(n$10:A*) virtual [line 36, column 20]\n *&#GB$A::test2.sharedInstance:objc_object*=n$11 [line 36, column 3]\n EXIT_SCOPE(n$10,n$11); [line 36, column 3]\n " shape="box"] +"test2#A#class.ce50cb13c3345decc567dd4eb6124604_5" [label="5: BinaryOperatorStmt: Assign \n n$10=_fun___objc_alloc_no_fail(sizeof(t=A):unsigned long) [line 36, column 21]\n n$11=_fun_NSObject::init(n$10:A*) virtual [line 36, column 20]\n *&#GB$A::test2.sharedInstance:objc_object*=n$11 [line 36, column 3]\n EXIT_SCOPE(n$10,n$11); [line 36, column 3]\n " shape="box"] "test2#A#class.ce50cb13c3345decc567dd4eb6124604_5" -> "test2#A#class.ce50cb13c3345decc567dd4eb6124604_4" ; diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.m.dot b/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.m.dot index c63165ec5..11ae8dc42 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.m.dot +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.m.dot @@ -90,11 +90,11 @@ digraph cfg { "getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_2" [label="2: Exit Boxing::getS \n " color=yellow style=filled] -"getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_3" [label="3: Return Stmt \n n$15=_fun_NSString::stringWithUTF8String:((char const *)\"hello world\":char const *) [line 41, column 10]\n *&return:NSString*=n$15 [line 41, column 3]\n EXIT_SCOPE(n$15); [line 41, column 3]\n APPLY_ABSTRACTION; [line 41, column 3]\n " shape="box"] +"getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_3" [label="3: Return Stmt \n n$15=_fun_NSString::stringWithUTF8String:(\"hello world\":char*) [line 41, column 10]\n *&return:NSString*=n$15 [line 41, column 3]\n EXIT_SCOPE(n$15); [line 41, column 3]\n APPLY_ABSTRACTION; [line 41, column 3]\n " shape="box"] "getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_3" -> "getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_2" ; -"getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:NSString*); [line 40, column 3]\n n$16=_fun_strdup((char const *)\"hello world\":char const *) [line 40, column 19]\n n$17=_fun_NSString::stringWithUTF8String:((char const *)n$16:char const *) [line 40, column 17]\n *&s:NSString*=n$17 [line 40, column 3]\n NULLIFY(&s); [line 40, column 3]\n EXIT_SCOPE(n$16,n$17,s); [line 40, column 3]\n " shape="box"] +"getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:NSString*); [line 40, column 3]\n n$16=_fun_strdup(\"hello world\":char*) [line 40, column 19]\n n$17=_fun_NSString::stringWithUTF8String:(n$16:char*) [line 40, column 17]\n *&s:NSString*=n$17 [line 40, column 3]\n NULLIFY(&s); [line 40, column 3]\n EXIT_SCOPE(n$16,n$17,s); [line 40, column 3]\n " shape="box"] "getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_4" -> "getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_3" ; diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.c.dot b/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.c.dot index 140c452ef..5cbfdc664 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.c.dot +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.c.dot @@ -7,7 +7,7 @@ digraph cfg { "get_string1.37988b3a9459aa3258beba816a2c79fc_2" [label="2: Exit get_string1 \n " color=yellow style=filled] -"get_string1.37988b3a9459aa3258beba816a2c79fc_3" [label="3: Return Stmt \n n$0=_fun_NSString::stringWithUTF8String:((char const *)\"Hello World!\":char const *) [line 12, column 10]\n *&return:NSString*=n$0 [line 12, column 3]\n EXIT_SCOPE(n$0); [line 12, column 3]\n APPLY_ABSTRACTION; [line 12, column 3]\n " shape="box"] +"get_string1.37988b3a9459aa3258beba816a2c79fc_3" [label="3: Return Stmt \n n$0=_fun_NSString::stringWithUTF8String:(\"Hello World!\":char*) [line 12, column 10]\n *&return:NSString*=n$0 [line 12, column 3]\n EXIT_SCOPE(n$0); [line 12, column 3]\n APPLY_ABSTRACTION; [line 12, column 3]\n " shape="box"] "get_string1.37988b3a9459aa3258beba816a2c79fc_3" -> "get_string1.37988b3a9459aa3258beba816a2c79fc_2" ; diff --git a/infer/tests/codetoanalyze/objc/shared/block/dispatch.m.dot b/infer/tests/codetoanalyze/objc/shared/block/dispatch.m.dot index 96517c439..ca2424ca8 100644 --- a/infer/tests/codetoanalyze/objc/shared/block/dispatch.m.dot +++ b/infer/tests/codetoanalyze/objc/shared/block/dispatch.m.dot @@ -62,7 +62,7 @@ digraph cfg { "objc_blockDispatchA::dispatch_a_block_variable_4.0b9ca2975d7f2bf9120661b118c2c0bb_2" [label="2: Exit objc_blockDispatchA::dispatch_a_block_variable_4 \n " color=yellow style=filled] -"objc_blockDispatchA::dispatch_a_block_variable_4.0b9ca2975d7f2bf9120661b118c2c0bb_3" [label="3: BinaryOperatorStmt: Assign \n n$20=_fun___objc_alloc_no_fail(sizeof(t=DispatchA):unsigned long) [line 55, column 25]\n n$21=_fun_NSObject::init(n$20:DispatchA*) virtual [line 55, column 25]\n *&#GB$DispatchA::dispatch_a_block_variable.static_storage__:objc_object*=n$21 [line 55, column 5]\n EXIT_SCOPE(n$20,n$21); [line 55, column 5]\n APPLY_ABSTRACTION; [line 55, column 5]\n " shape="box"] +"objc_blockDispatchA::dispatch_a_block_variable_4.0b9ca2975d7f2bf9120661b118c2c0bb_3" [label="3: BinaryOperatorStmt: Assign \n n$20=_fun___objc_alloc_no_fail(sizeof(t=DispatchA):unsigned long) [line 55, column 25]\n n$21=_fun_NSObject::init(n$20:DispatchA*) virtual [line 55, column 25]\n *&#GB$DispatchA::dispatch_a_block_variable.static_storage__:DispatchA*=n$21 [line 55, column 5]\n EXIT_SCOPE(n$20,n$21); [line 55, column 5]\n APPLY_ABSTRACTION; [line 55, column 5]\n " shape="box"] "objc_blockDispatchA::dispatch_a_block_variable_4.0b9ca2975d7f2bf9120661b118c2c0bb_3" -> "objc_blockDispatchA::dispatch_a_block_variable_4.0b9ca2975d7f2bf9120661b118c2c0bb_2" ; @@ -73,7 +73,7 @@ digraph cfg { "objc_blockDispatchA::dispatch_a_block_variable_from_macro_5.95f7628ee6d5ad3dae46b578932c94aa_2" [label="2: Exit objc_blockDispatchA::dispatch_a_block_variable_from_macro_5 \n " color=yellow style=filled] -"objc_blockDispatchA::dispatch_a_block_variable_from_macro_5.95f7628ee6d5ad3dae46b578932c94aa_3" [label="3: BinaryOperatorStmt: Assign \n n$25=_fun___objc_alloc_no_fail(sizeof(t=DispatchA):unsigned long) [line 66, column 27]\n n$26=_fun_NSObject::init(n$25:DispatchA*) virtual [line 66, column 27]\n *&#GB$DispatchA::dispatch_a_block_variable_from_macro.static_storage__:objc_object*=n$26 [line 66, column 7]\n EXIT_SCOPE(n$25,n$26); [line 66, column 7]\n APPLY_ABSTRACTION; [line 66, column 7]\n " shape="box"] +"objc_blockDispatchA::dispatch_a_block_variable_from_macro_5.95f7628ee6d5ad3dae46b578932c94aa_3" [label="3: BinaryOperatorStmt: Assign \n n$25=_fun___objc_alloc_no_fail(sizeof(t=DispatchA):unsigned long) [line 66, column 27]\n n$26=_fun_NSObject::init(n$25:DispatchA*) virtual [line 66, column 27]\n *&#GB$DispatchA::dispatch_a_block_variable_from_macro.static_storage__:DispatchA*=n$26 [line 66, column 7]\n EXIT_SCOPE(n$25,n$26); [line 66, column 7]\n APPLY_ABSTRACTION; [line 66, column 7]\n " shape="box"] "objc_blockDispatchA::dispatch_a_block_variable_from_macro_5.95f7628ee6d5ad3dae46b578932c94aa_3" -> "objc_blockDispatchA::dispatch_a_block_variable_from_macro_5.95f7628ee6d5ad3dae46b578932c94aa_2" ; @@ -84,7 +84,7 @@ digraph cfg { "objc_blockDispatchA::sharedInstance_1.50704f3ac0a3af5feaadec9b1fbbe54d_2" [label="2: Exit objc_blockDispatchA::sharedInstance_1 \n " color=yellow style=filled] -"objc_blockDispatchA::sharedInstance_1.50704f3ac0a3af5feaadec9b1fbbe54d_3" [label="3: BinaryOperatorStmt: Assign \n n$2=_fun___objc_alloc_no_fail(sizeof(t=DispatchA):unsigned long) [line 29, column 23]\n n$3=_fun_NSBundleResourceRequest::init(n$2:DispatchA*) virtual [line 29, column 22]\n *&#GB$DispatchA::sharedInstance.sharedInstance:objc_object*=n$3 [line 29, column 5]\n EXIT_SCOPE(n$2,n$3); [line 29, column 5]\n APPLY_ABSTRACTION; [line 29, column 5]\n " shape="box"] +"objc_blockDispatchA::sharedInstance_1.50704f3ac0a3af5feaadec9b1fbbe54d_3" [label="3: BinaryOperatorStmt: Assign \n n$2=_fun___objc_alloc_no_fail(sizeof(t=DispatchA):unsigned long) [line 29, column 23]\n n$3=_fun_DispatchA::init(n$2:DispatchA*) virtual [line 29, column 22]\n *&#GB$DispatchA::sharedInstance.sharedInstance:objc_object*=n$3 [line 29, column 5]\n EXIT_SCOPE(n$2,n$3); [line 29, column 5]\n APPLY_ABSTRACTION; [line 29, column 5]\n " shape="box"] "objc_blockDispatchA::sharedInstance_1.50704f3ac0a3af5feaadec9b1fbbe54d_3" -> "objc_blockDispatchA::sharedInstance_1.50704f3ac0a3af5feaadec9b1fbbe54d_2" ; @@ -95,7 +95,7 @@ digraph cfg { "objc_blockDispatchA::trans_3.95a17d9ac15f0da3f92b7057c890d96c_2" [label="2: Exit objc_blockDispatchA::trans_3 \n " color=yellow style=filled] -"objc_blockDispatchA::trans_3.95a17d9ac15f0da3f92b7057c890d96c_3" [label="3: BinaryOperatorStmt: Assign \n n$15=_fun___objc_alloc_no_fail(sizeof(t=DispatchA):unsigned long) [line 46, column 23]\n n$16=_fun_NSBundleResourceRequest::init(n$15:DispatchA*) virtual [line 46, column 22]\n *&#GB$DispatchA::trans.sharedInstance:objc_object*=n$16 [line 46, column 5]\n EXIT_SCOPE(n$15,n$16); [line 46, column 5]\n APPLY_ABSTRACTION; [line 46, column 5]\n " shape="box"] +"objc_blockDispatchA::trans_3.95a17d9ac15f0da3f92b7057c890d96c_3" [label="3: BinaryOperatorStmt: Assign \n n$15=_fun___objc_alloc_no_fail(sizeof(t=DispatchA):unsigned long) [line 46, column 23]\n n$16=_fun_DispatchA::init(n$15:DispatchA*) virtual [line 46, column 22]\n *&#GB$DispatchA::trans.sharedInstance:objc_object*=n$16 [line 46, column 5]\n EXIT_SCOPE(n$15,n$16); [line 46, column 5]\n APPLY_ABSTRACTION; [line 46, column 5]\n " shape="box"] "objc_blockDispatchA::trans_3.95a17d9ac15f0da3f92b7057c890d96c_3" -> "objc_blockDispatchA::trans_3.95a17d9ac15f0da3f92b7057c890d96c_2" ; @@ -125,7 +125,7 @@ digraph cfg { "dispatch_a_block_variable#DispatchA#class.3cc12dd22127281b8293b7c046d21bb2_2" [label="2: Exit DispatchA::dispatch_a_block_variable \n " color=yellow style=filled] -"dispatch_a_block_variable#DispatchA#class.3cc12dd22127281b8293b7c046d21bb2_3" [label="3: Return Stmt \n n$17=*&#GB$DispatchA::dispatch_a_block_variable.static_storage__:objc_object* [line 59, column 10]\n *&return:objc_object*=n$17 [line 59, column 3]\n EXIT_SCOPE(n$17); [line 59, column 3]\n APPLY_ABSTRACTION; [line 59, column 3]\n " shape="box"] +"dispatch_a_block_variable#DispatchA#class.3cc12dd22127281b8293b7c046d21bb2_3" [label="3: Return Stmt \n n$17=*&#GB$DispatchA::dispatch_a_block_variable.static_storage__:DispatchA* [line 59, column 10]\n *&return:objc_object*=n$17 [line 59, column 3]\n EXIT_SCOPE(n$17); [line 59, column 3]\n APPLY_ABSTRACTION; [line 59, column 3]\n " shape="box"] "dispatch_a_block_variable#DispatchA#class.3cc12dd22127281b8293b7c046d21bb2_3" -> "dispatch_a_block_variable#DispatchA#class.3cc12dd22127281b8293b7c046d21bb2_2" ; @@ -144,7 +144,7 @@ digraph cfg { "dispatch_a_block_variable_from_macro#DispatchA#class.92567a38d5ab3cf637f72030b1097441_2" [label="2: Exit DispatchA::dispatch_a_block_variable_from_macro \n " color=yellow style=filled] -"dispatch_a_block_variable_from_macro#DispatchA#class.92567a38d5ab3cf637f72030b1097441_3" [label="3: Fallback node \n n$22=*&#GB$DispatchA::dispatch_a_block_variable_from_macro.static_storage__:objc_object* [line 70, column 5]\n " shape="box"] +"dispatch_a_block_variable_from_macro#DispatchA#class.92567a38d5ab3cf637f72030b1097441_3" [label="3: Fallback node \n n$22=*&#GB$DispatchA::dispatch_a_block_variable_from_macro.static_storage__:DispatchA* [line 70, column 5]\n " shape="box"] "dispatch_a_block_variable_from_macro#DispatchA#class.92567a38d5ab3cf637f72030b1097441_3" -> "dispatch_a_block_variable_from_macro#DispatchA#class.92567a38d5ab3cf637f72030b1097441_6" ; diff --git a/infer/tests/codetoanalyze/objc/shared/memory_leaks_benchmark/TollBridgeExample.m.dot b/infer/tests/codetoanalyze/objc/shared/memory_leaks_benchmark/TollBridgeExample.m.dot index cb2dc6a15..435af07cb 100644 --- a/infer/tests/codetoanalyze/objc/shared/memory_leaks_benchmark/TollBridgeExample.m.dot +++ b/infer/tests/codetoanalyze/objc/shared/memory_leaks_benchmark/TollBridgeExample.m.dot @@ -22,7 +22,7 @@ digraph cfg { "cfautorelease_test.2ccea2233b65cd3828a2d5e2571ad69b_2" [label="2: Exit cfautorelease_test \n " color=yellow style=filled] -"cfautorelease_test.2ccea2233b65cd3828a2d5e2571ad69b_3" [label="3: Return Stmt \n n$0=_fun___builtin___CFStringMakeConstantString((char const *)\"Icon\":char const *) [line 39, column 45]\n n$1=_fun_CTFontCreateWithName(n$0:__CFString const *,17.:double,null:CGAffineTransform const *) [line 39, column 24]\n n$2=_fun_CFAutorelease(n$1:void const *) [line 39, column 10]\n *&return:__CTFont const *=n$2 [line 39, column 3]\n EXIT_SCOPE(n$0,n$1,n$2); [line 39, column 3]\n APPLY_ABSTRACTION; [line 39, column 3]\n " shape="box"] +"cfautorelease_test.2ccea2233b65cd3828a2d5e2571ad69b_3" [label="3: Return Stmt \n n$0=_fun___builtin___CFStringMakeConstantString(\"Icon\":char*) [line 39, column 45]\n n$1=_fun_CTFontCreateWithName(n$0:__CFString const *,17.:double,null:CGAffineTransform const *) [line 39, column 24]\n n$2=_fun_CFAutorelease(n$1:void const *) [line 39, column 10]\n *&return:__CTFont const *=n$2 [line 39, column 3]\n EXIT_SCOPE(n$0,n$1,n$2); [line 39, column 3]\n APPLY_ABSTRACTION; [line 39, column 3]\n " shape="box"] "cfautorelease_test.2ccea2233b65cd3828a2d5e2571ad69b_3" -> "cfautorelease_test.2ccea2233b65cd3828a2d5e2571ad69b_2" ;