diff --git a/infer/src/clang/ast_expressions.ml b/infer/src/clang/ast_expressions.ml index b00d7adb2..782d49b2f 100644 --- a/infer/src/clang/ast_expressions.ml +++ b/infer/src/clang/ast_expressions.ml @@ -9,11 +9,6 @@ open! IStd -let stmt_info_with_fresh_pointer stmt_info = - { Clang_ast_t.si_pointer= CAst_utils.get_fresh_pointer () - ; si_source_range= stmt_info.Clang_ast_t.si_source_range } - - let create_qual_type ?(quals = Typ.mk_type_quals ()) qt_type_ptr = { Clang_ast_t.qt_type_ptr ; qt_is_const= Typ.is_const quals @@ -45,6 +40,56 @@ let create_class_qual_type ?quals typename = create_qual_type ?quals (Clang_ast_extend.ClassType typename) +let create_class_pointer_qual_type ?quals typename = + create_pointer_qual_type ?quals (create_class_qual_type ?quals typename) + + +let create_decl_info stmt_info pointer = + { Clang_ast_t.di_pointer= pointer + ; di_parent_pointer= None + ; di_source_range= stmt_info.Clang_ast_t.si_source_range + ; di_owning_module= None + ; di_is_hidden= false + ; di_is_implicit= false + ; di_is_used= true + ; di_is_this_declaration_referenced= true + ; di_is_invalid_decl= false + ; di_attributes= [] + ; di_full_comment= None + ; di_access= `None } + + +let default_var_decl_info = + { Clang_ast_t.vdi_is_global= false + ; vdi_is_extern= false + ; vdi_is_static= false + ; vdi_is_static_local= false + ; vdi_is_static_data_member= false + ; vdi_is_const_expr= false + ; vdi_is_init_ice= false + ; vdi_init_expr= None + ; vdi_is_init_expr_cxx11_constant= false + ; vdi_parm_index_in_function= None } + + +let create_named_decl_info name = {Clang_ast_t.ni_name= name; ni_qual_name= [name]} + +let create_decl_ref pointer ni qual_type = + { Clang_ast_t.dr_kind= `Var + ; dr_decl_pointer= pointer + ; dr_name= Some ni + ; dr_is_hidden= false + ; dr_qual_type= Some qual_type } + + +let create_decl_ref_expr stmt_info pointer ni qual_type = + Clang_ast_t.DeclRefExpr + ( stmt_info + , [] + , {ei_qual_type= qual_type; ei_value_kind= `LValue; ei_object_kind= `Ordinary} + , {drti_decl_ref= Some (create_decl_ref pointer ni qual_type); drti_found_decl_ref= None} ) + + let create_integer_literal n = let stmt_info = CAst_utils.dummy_stmt_info () in let expr_info = @@ -88,19 +133,6 @@ let create_nil stmt_info = create_implicit_cast_expr stmt_info [paren_expr] create_id_type `NullToPointer -let make_expr_info qt vk objc_kind = - {Clang_ast_t.ei_qual_type= qt; ei_value_kind= vk; ei_object_kind= objc_kind} - - -let make_expr_info_with_objc_kind qt objc_kind = make_expr_info qt `LValue objc_kind - -let make_obj_c_message_expr_info_instance sel = - { Clang_ast_t.omei_selector= sel - ; omei_receiver_kind= `Instance - ; omei_is_definition_found= false - ; omei_decl_pointer= None (* TODO look into it *) } - - let make_obj_c_message_expr_info_class selector tname pointer = { Clang_ast_t.omei_selector= selector ; omei_receiver_kind= `Class (create_class_qual_type tname) @@ -108,78 +140,15 @@ let make_obj_c_message_expr_info_class selector tname pointer = ; omei_decl_pointer= pointer } -let make_decl_ref k decl_ptr name is_hidden qt_opt = - { Clang_ast_t.dr_kind= k - ; dr_decl_pointer= decl_ptr - ; dr_name= Some name - ; dr_is_hidden= is_hidden - ; dr_qual_type= qt_opt } - - -let make_decl_ref_qt k decl_ptr name is_hidden qt = - make_decl_ref k decl_ptr name is_hidden (Some qt) - - -let make_decl_ref_expr_info decl_ref = - {Clang_ast_t.drti_decl_ref= Some decl_ref; drti_found_decl_ref= None} - - -let make_message_expr param_qt selector decl_ref_exp stmt_info add_cast = - let stmt_info = stmt_info_with_fresh_pointer stmt_info in - let parameters = - if add_cast then - let cast_expr = create_implicit_cast_expr stmt_info [decl_ref_exp] param_qt `LValueToRValue in - [cast_expr] - else [decl_ref_exp] - in - let obj_c_message_expr_info = make_obj_c_message_expr_info_instance selector in - let expr_info = make_expr_info_with_objc_kind param_qt `ObjCProperty in - Clang_ast_t.ObjCMessageExpr (stmt_info, parameters, expr_info, obj_c_message_expr_info) - - -let make_binary_stmt stmt1 stmt2 stmt_info expr_info boi = - let stmt_info = stmt_info_with_fresh_pointer stmt_info in - Clang_ast_t.BinaryOperator (stmt_info, [stmt1; stmt2], expr_info, boi) - - -let make_next_object_exp stmt_info item items = - let rec get_decl_ref item = - match item with - | Clang_ast_t.DeclStmt (_, _, [Clang_ast_t.VarDecl (di, name_info, var_qual_type, _)]) -> - let decl_ptr = di.Clang_ast_t.di_pointer in - let decl_ref = make_decl_ref_qt `Var decl_ptr name_info false var_qual_type in - let stmt_info_var = - { Clang_ast_t.si_pointer= di.Clang_ast_t.di_pointer - ; si_source_range= di.Clang_ast_t.di_source_range } - in - let expr_info = make_expr_info_with_objc_kind var_qual_type `ObjCProperty in - let decl_ref_expr_info = make_decl_ref_expr_info decl_ref in - (Clang_ast_t.DeclRefExpr (stmt_info_var, [], expr_info, decl_ref_expr_info), var_qual_type) - | Clang_ast_t.DeclRefExpr (_, _, expr_info, _) -> - (item, expr_info.Clang_ast_t.ei_qual_type) - | stmt -> ( - let _, stmts = Clang_ast_proj.get_stmt_tuple stmt in - match stmts with - | [stmt] -> - get_decl_ref stmt - | _ -> - CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range - "unexpected item %a" - (Pp.of_string ~f:Clang_ast_j.string_of_stmt) - item ) - in - let var_decl_ref, var_type = get_decl_ref item in - let message_call = - make_message_expr create_id_type CFrontend_config.next_object items stmt_info false - in - let boi = {Clang_ast_t.boi_kind= `Assign} in - let expr_info = make_expr_info_with_objc_kind var_type `ObjCProperty in - let assignment = make_binary_stmt var_decl_ref message_call stmt_info expr_info boi in - let boi' = {Clang_ast_t.boi_kind= `NE} in - let cast = create_implicit_cast_expr stmt_info [var_decl_ref] var_type `LValueToRValue in - let nil_exp = create_nil stmt_info in - let loop_cond = make_binary_stmt cast nil_exp stmt_info expr_info boi' in - (assignment, loop_cond) +let create_obj_c_message_expr stmt_info qual_type selector args = + Clang_ast_t.ObjCMessageExpr + ( stmt_info + , args + , {ei_qual_type= qual_type; ei_value_kind= `RValue; ei_object_kind= `Ordinary} + , { omei_selector= selector + ; omei_is_definition_found= false + ; omei_decl_pointer= None + ; omei_receiver_kind= `Instance } ) (* We translate an expression with a conditional*) diff --git a/infer/src/clang/ast_expressions.mli b/infer/src/clang/ast_expressions.mli index 4c0b68db8..50ca5c355 100644 --- a/infer/src/clang/ast_expressions.mli +++ b/infer/src/clang/ast_expressions.mli @@ -18,13 +18,22 @@ val create_void_type : qual_type val create_char_star_type : ?quals:Typ.type_quals -> unit -> qual_type -val make_next_object_exp : - stmt_info -> stmt -> Clang_ast_t.stmt -> Clang_ast_t.stmt * Clang_ast_t.stmt +val create_class_pointer_qual_type : ?quals:Typ.type_quals -> Typ.Name.t -> qual_type val create_nil : stmt_info -> stmt val create_implicit_cast_expr : stmt_info -> stmt list -> qual_type -> cast_kind -> stmt +val create_decl_info : stmt_info -> pointer -> decl_info + +val default_var_decl_info : var_decl_info + +val create_named_decl_info : string -> named_decl_info + +val create_decl_ref_expr : stmt_info -> pointer -> named_decl_info -> qual_type -> stmt + +val create_obj_c_message_expr : stmt_info -> qual_type -> selector -> stmt list -> stmt + val make_obj_c_message_expr_info_class : string -> Typ.Name.t -> pointer option -> obj_c_message_expr_info diff --git a/infer/src/clang/cFrontend_config.ml b/infer/src/clang/cFrontend_config.ml index a443ee0c0..95d0f4577 100644 --- a/infer/src/clang/cFrontend_config.ml +++ b/infer/src/clang/cFrontend_config.ml @@ -77,6 +77,8 @@ let new_str = "new" let next_object = "nextObject" +let nsenumerator_cl = "NSEnumerator" + let nsproxy_cl = "NSProxy" let nsobject_cl = "NSObject" @@ -87,6 +89,8 @@ let objc_class = "objc_class" let objc_object = "objc_object" +let object_enumerator = "objectEnumerator" + let return_param = "__return_param" let self = "self" diff --git a/infer/src/clang/cFrontend_config.mli b/infer/src/clang/cFrontend_config.mli index 711d46ddc..e5d8ff9bb 100644 --- a/infer/src/clang/cFrontend_config.mli +++ b/infer/src/clang/cFrontend_config.mli @@ -71,6 +71,8 @@ val new_str : string val next_object : string +val nsenumerator_cl : string + val nsproxy_cl : string val nsobject_cl : string @@ -81,6 +83,8 @@ val objc_class : string val objc_object : string +val object_enumerator : string + val return_param : string val self : string diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 2a74553f4..72f81c1c8 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -2218,20 +2218,81 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s (** Fast iteration for collections - [for (type_it i in collection) { body }] is translated as + [for (item_type item in items) { body }] is translated as {[ - i = type_next_object(); - while(i != nil) { body; i = type_next_object();} + NSEnumerator *enumerator = [items objectEnumerator]; + item_type item; + while (item = [enumerator nextObject]) { body } ]} *) - and objCForCollectionStmt_trans trans_state item items body stmt_info = - ignore (instruction trans_state item) ; - (* Here we do ast transformation, so we don't need the value of the translation of the *) - (* 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 loop = Clang_ast_t.WhileStmt (stmt_info, [cond; body']) in - instruction trans_state (Clang_ast_t.CompoundStmt (stmt_info, [assign_next_object; loop])) + and objCForCollectionStmt_trans ({context= {procdesc}} as trans_state) item items body stmt_info = + match item with + | Clang_ast_t.DeclRefExpr + ( _ + , _ + , _ + , { drti_decl_ref= + Some + { dr_decl_pointer= item_pointer + ; dr_name= Some item_ni + ; dr_qual_type= Some item_qual_type } } ) + | Clang_ast_t.DeclStmt (_, _, [VarDecl ({di_pointer= item_pointer}, item_ni, item_qual_type, _)]) + -> + let enumerator_type = + Ast_expressions.create_class_pointer_qual_type + (Typ.Name.Objc.from_string CFrontend_config.nsenumerator_cl) + in + let enumerator_pointer = CAst_utils.get_fresh_pointer () in + let enumerator_ni = + let pvar = Pvar.mk_tmp "__enumerator_" (Procdesc.get_proc_name procdesc) in + Ast_expressions.create_named_decl_info (Pvar.to_string pvar) + in + let enumerator_decl = + let object_enumerator_objc_message_expr = + Ast_expressions.create_obj_c_message_expr stmt_info enumerator_type + CFrontend_config.object_enumerator [items] + in + let var_decl = + Clang_ast_t.VarDecl + ( Ast_expressions.create_decl_info stmt_info enumerator_pointer + , enumerator_ni + , enumerator_type + , { Ast_expressions.default_var_decl_info with + vdi_init_expr= Some object_enumerator_objc_message_expr } ) + in + Clang_ast_t.DeclStmt (stmt_info, [object_enumerator_objc_message_expr], [var_decl]) + in + let while_stmt = + let item_expr = + Ast_expressions.create_decl_ref_expr stmt_info item_pointer item_ni item_qual_type + in + let enumerator_expr = + let enumerator_decl_ref_expr = + Ast_expressions.create_decl_ref_expr stmt_info enumerator_pointer enumerator_ni + enumerator_type + in + Ast_expressions.create_implicit_cast_expr stmt_info [enumerator_decl_ref_expr] + enumerator_type `LValueToRValue + in + let next_object_call = + Ast_expressions.create_obj_c_message_expr stmt_info enumerator_type + CFrontend_config.next_object [enumerator_expr] + in + let cond = + Clang_ast_t.BinaryOperator + ( stmt_info + , [item_expr; next_object_call] + , {ei_qual_type= item_qual_type; ei_value_kind= `RValue; ei_object_kind= `Ordinary} + , {boi_kind= `Assign} ) + in + Clang_ast_t.WhileStmt (stmt_info, [cond; body]) + in + instruction trans_state + (Clang_ast_t.CompoundStmt (stmt_info, [enumerator_decl; item; while_stmt])) + | _ -> + L.debug Capture Medium "Couldn't translate ObjCForCollectionStmt properly: %s@\n" + (Clang_ast_j.string_of_stmt_info stmt_info) ; + mk_trans_result (mk_fresh_void_exp_typ ()) empty_control and initListExpr_array_trans trans_state stmt_info stmts var_exp field_typ = diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/array.m.dot b/infer/tests/codetoanalyze/objc/frontend/boxing/array.m.dot index a9ba7cac6..d9a51ca5c 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/array.m.dot +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/array.m.dot @@ -1,9 +1,9 @@ /* @generated */ digraph cfg { -"main.fad58de7366495db4650cfefac2fcd61_1" [label="1: Start main\nFormals: \nLocals: item:NSString* germanCars:NSArray* 0$?%__sil_tmpSIL_arrayWithObjects_count___n$11:objc_object* const [6*8] s:NSString* \n " color=yellow style=filled] +"main.fad58de7366495db4650cfefac2fcd61_1" [label="1: Start main\nFormals: \nLocals: item:NSString* 0$?%__sil_tmp__enumerator_n$0:NSEnumerator* germanCars:NSArray* 0$?%__sil_tmpSIL_arrayWithObjects_count___n$12:objc_object* const [6*8] s:NSString* \n " color=yellow style=filled] - "main.fad58de7366495db4650cfefac2fcd61_1" -> "main.fad58de7366495db4650cfefac2fcd61_12" ; + "main.fad58de7366495db4650cfefac2fcd61_1" -> "main.fad58de7366495db4650cfefac2fcd61_13" ; "main.fad58de7366495db4650cfefac2fcd61_2" [label="2: Exit main \n " color=yellow style=filled] @@ -15,37 +15,41 @@ digraph cfg { "main.fad58de7366495db4650cfefac2fcd61_4" -> "main.fad58de7366495db4650cfefac2fcd61_5" ; -"main.fad58de7366495db4650cfefac2fcd61_5" [label="5: BinaryOperatorStmt: NE \n n$0=*&item:NSString* [line 24, column 3]\n " shape="box"] +"main.fad58de7366495db4650cfefac2fcd61_5" [label="5: Message Call: nextObject \n n$1=*&0$?%__sil_tmp__enumerator_n$0:NSEnumerator* [line 24, column 3]\n n$2=_fun_NSEnumerator.nextObject(n$1:NSEnumerator*) virtual [line 24, column 3]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_5" -> "main.fad58de7366495db4650cfefac2fcd61_6" ; - "main.fad58de7366495db4650cfefac2fcd61_5" -> "main.fad58de7366495db4650cfefac2fcd61_7" ; -"main.fad58de7366495db4650cfefac2fcd61_6" [label="6: Prune (true branch, while) \n PRUNE((n$0 != null), true); [line 24, column 3]\n " shape="invhouse"] +"main.fad58de7366495db4650cfefac2fcd61_6" [label="6: BinaryOperatorStmt: Assign \n *&item:NSString*=n$2 [line 24, column 3]\n n$3=*&item:NSString* [line 24, column 3]\n " shape="box"] - "main.fad58de7366495db4650cfefac2fcd61_6" -> "main.fad58de7366495db4650cfefac2fcd61_9" ; -"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: Prune (false branch, while) \n PRUNE(!(n$0 != null), false); [line 24, column 3]\n " shape="invhouse"] + "main.fad58de7366495db4650cfefac2fcd61_6" -> "main.fad58de7366495db4650cfefac2fcd61_7" ; + "main.fad58de7366495db4650cfefac2fcd61_6" -> "main.fad58de7366495db4650cfefac2fcd61_8" ; +"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: Prune (true branch, while) \n PRUNE(n$3, true); [line 24, column 3]\n " shape="invhouse"] - "main.fad58de7366495db4650cfefac2fcd61_7" -> "main.fad58de7366495db4650cfefac2fcd61_3" ; -"main.fad58de7366495db4650cfefac2fcd61_8" [label="8: BinaryOperatorStmt: Assign \n n$1=*&germanCars:NSArray* [line 24, column 26]\n n$2=_fun_NSArray.nextObject(n$1:NSArray*) virtual [line 24, column 3]\n *&item:NSString*=n$2 [line 24, column 3]\n " shape="box"] + "main.fad58de7366495db4650cfefac2fcd61_7" -> "main.fad58de7366495db4650cfefac2fcd61_9" ; +"main.fad58de7366495db4650cfefac2fcd61_8" [label="8: Prune (false branch, while) \n PRUNE(!n$3, false); [line 24, column 3]\n " shape="invhouse"] - "main.fad58de7366495db4650cfefac2fcd61_8" -> "main.fad58de7366495db4650cfefac2fcd61_4" ; -"main.fad58de7366495db4650cfefac2fcd61_9" [label="9: Call _fun_NSLog \n n$3=_fun_NSString.stringWithUTF8String:(\"%@\":char* const ) [line 25, column 11]\n n$4=*&item:NSString* [line 25, column 18]\n n$5=_fun_NSLog(n$3:objc_object*,n$4:NSString*) [line 25, column 5]\n " shape="box"] + "main.fad58de7366495db4650cfefac2fcd61_8" -> "main.fad58de7366495db4650cfefac2fcd61_3" ; +"main.fad58de7366495db4650cfefac2fcd61_9" [label="9: Call _fun_NSLog \n n$4=_fun_NSString.stringWithUTF8String:(\"%@\":char* const ) [line 25, column 11]\n n$5=*&item:NSString* [line 25, column 18]\n n$6=_fun_NSLog(n$4:objc_object*,n$5:NSString*) [line 25, column 5]\n " shape="box"] - "main.fad58de7366495db4650cfefac2fcd61_9" -> "main.fad58de7366495db4650cfefac2fcd61_8" ; -"main.fad58de7366495db4650cfefac2fcd61_10" [label="10: BinaryOperatorStmt: Assign \n n$7=*&germanCars:NSArray* [line 24, column 26]\n n$8=_fun_NSArray.nextObject(n$7:NSArray*) virtual [line 24, column 3]\n *&item:NSString*=n$8 [line 24, column 3]\n " shape="box"] + "main.fad58de7366495db4650cfefac2fcd61_9" -> "main.fad58de7366495db4650cfefac2fcd61_4" ; +"main.fad58de7366495db4650cfefac2fcd61_10" [label="10: Message Call: objectEnumerator \n n$8=*&germanCars:NSArray* [line 24, column 26]\n n$9=_fun_NSArray.objectEnumerator(n$8:NSArray*) virtual [line 24, column 3]\n " shape="box"] - "main.fad58de7366495db4650cfefac2fcd61_10" -> "main.fad58de7366495db4650cfefac2fcd61_4" ; -"main.fad58de7366495db4650cfefac2fcd61_11" [label="11: BinaryOperatorStmt: Assign \n n$9=*&germanCars:NSArray* [line 22, column 7]\n n$10=_fun_NSArray.objectAtIndexedSubscript:(n$9:NSArray*,(unsigned long)3:unsigned long) virtual [line 22, column 7]\n *&s:NSString*=n$10 [line 22, column 3]\n " shape="box"] + "main.fad58de7366495db4650cfefac2fcd61_10" -> "main.fad58de7366495db4650cfefac2fcd61_11" ; +"main.fad58de7366495db4650cfefac2fcd61_11" [label="11: DeclStmt \n VARIABLE_DECLARED(0$?%__sil_tmp__enumerator_n$0:NSEnumerator*); [line 24, column 3]\n *&0$?%__sil_tmp__enumerator_n$0:NSEnumerator*=n$9 [line 24, column 3]\n " shape="box"] - "main.fad58de7366495db4650cfefac2fcd61_11" -> "main.fad58de7366495db4650cfefac2fcd61_10" ; -"main.fad58de7366495db4650cfefac2fcd61_12" [label="12: DeclStmt \n VARIABLE_DECLARED(germanCars:NSArray*); [line 14, column 3]\n n$12=_fun_NSString.stringWithUTF8String:(\"Mercedes-Benz\":char* const ) [line 15, column 5]\n n$13=_fun_NSString.stringWithUTF8String:(\"BMW\":char* const ) [line 16, column 5]\n n$14=_fun_NSString.stringWithUTF8String:(\"Porsche\":char* const ) [line 17, column 5]\n n$15=_fun_NSString.stringWithUTF8String:(\"Opel\":char* const ) [line 18, column 5]\n n$16=_fun_NSString.stringWithUTF8String:(\"Volkswagen\":char* const ) [line 19, column 5]\n n$17=_fun_NSString.stringWithUTF8String:(\"Audi\":char* const ) [line 20, column 5]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$11[0]:objc_object*=n$12 [line 14, column 25]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$11[1]:objc_object*=n$13 [line 14, column 25]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$11[2]:objc_object*=n$14 [line 14, column 25]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$11[3]:objc_object*=n$15 [line 14, column 25]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$11[4]:objc_object*=n$16 [line 14, column 25]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$11[5]:objc_object*=n$17 [line 14, column 25]\n n$18=_fun_NSArray.arrayWithObjects:count:(&0$?%__sil_tmpSIL_arrayWithObjects_count___n$11:objc_object* const [6*8],6:int) [line 14, column 25]\n *&germanCars:NSArray*=n$18 [line 14, column 3]\n " shape="box"] + "main.fad58de7366495db4650cfefac2fcd61_11" -> "main.fad58de7366495db4650cfefac2fcd61_4" ; +"main.fad58de7366495db4650cfefac2fcd61_12" [label="12: BinaryOperatorStmt: Assign \n n$10=*&germanCars:NSArray* [line 22, column 7]\n n$11=_fun_NSArray.objectAtIndexedSubscript:(n$10:NSArray*,(unsigned long)3:unsigned long) virtual [line 22, column 7]\n *&s:NSString*=n$11 [line 22, column 3]\n " shape="box"] - "main.fad58de7366495db4650cfefac2fcd61_12" -> "main.fad58de7366495db4650cfefac2fcd61_11" ; + "main.fad58de7366495db4650cfefac2fcd61_12" -> "main.fad58de7366495db4650cfefac2fcd61_10" ; +"main.fad58de7366495db4650cfefac2fcd61_13" [label="13: DeclStmt \n VARIABLE_DECLARED(germanCars:NSArray*); [line 14, column 3]\n n$13=_fun_NSString.stringWithUTF8String:(\"Mercedes-Benz\":char* const ) [line 15, column 5]\n n$14=_fun_NSString.stringWithUTF8String:(\"BMW\":char* const ) [line 16, column 5]\n n$15=_fun_NSString.stringWithUTF8String:(\"Porsche\":char* const ) [line 17, column 5]\n n$16=_fun_NSString.stringWithUTF8String:(\"Opel\":char* const ) [line 18, column 5]\n n$17=_fun_NSString.stringWithUTF8String:(\"Volkswagen\":char* const ) [line 19, column 5]\n n$18=_fun_NSString.stringWithUTF8String:(\"Audi\":char* const ) [line 20, column 5]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$12[0]:objc_object*=n$13 [line 14, column 25]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$12[1]:objc_object*=n$14 [line 14, column 25]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$12[2]:objc_object*=n$15 [line 14, column 25]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$12[3]:objc_object*=n$16 [line 14, column 25]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$12[4]:objc_object*=n$17 [line 14, column 25]\n *&0$?%__sil_tmpSIL_arrayWithObjects_count___n$12[5]:objc_object*=n$18 [line 14, column 25]\n n$19=_fun_NSArray.arrayWithObjects:count:(&0$?%__sil_tmpSIL_arrayWithObjects_count___n$12:objc_object* const [6*8],6:int) [line 14, column 25]\n *&germanCars:NSArray*=n$19 [line 14, column 3]\n " shape="box"] + + + "main.fad58de7366495db4650cfefac2fcd61_13" -> "main.fad58de7366495db4650cfefac2fcd61_12" ; } diff --git a/infer/tests/codetoanalyze/objc/frontend/fast_enumeration/Fast_enumeration.m.dot b/infer/tests/codetoanalyze/objc/frontend/fast_enumeration/Fast_enumeration.m.dot index e8fc2bddf..bf7d05f33 100644 --- a/infer/tests/codetoanalyze/objc/frontend/fast_enumeration/Fast_enumeration.m.dot +++ b/infer/tests/codetoanalyze/objc/frontend/fast_enumeration/Fast_enumeration.m.dot @@ -11,10 +11,10 @@ digraph cfg { "dealloc#A#instance.55ac864e91dcd5d484e8ab7d8eb94fcb_3" -> "dealloc#A#instance.55ac864e91dcd5d484e8ab7d8eb94fcb_2" ; -"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_1" [label="1: Start A.fast_loop:\nFormals: self:A* items:NSArray*\nLocals: item:NSArray* size:int \n " color=yellow style=filled] +"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_1" [label="1: Start A.fast_loop:\nFormals: self:A* items:NSArray*\nLocals: item:NSArray* 0$?%__sil_tmp__enumerator_n$1:NSEnumerator* size:int \n " color=yellow style=filled] - "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_1" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_11" ; + "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_1" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_12" ; "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_2" [label="2: Exit A.fast_loop: \n " color=yellow style=filled] @@ -26,39 +26,43 @@ digraph cfg { "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_4" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_5" ; -"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_5" [label="5: BinaryOperatorStmt: NE \n n$1=*&item:NSArray* [line 21, column 3]\n " shape="box"] +"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_5" [label="5: Message Call: nextObject \n n$2=*&0$?%__sil_tmp__enumerator_n$1:NSEnumerator* [line 21, column 3]\n n$3=_fun_NSEnumerator.nextObject(n$2:NSEnumerator*) virtual [line 21, column 3]\n " shape="box"] "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_5" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_6" ; - "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_5" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_7" ; -"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_6" [label="6: Prune (true branch, while) \n PRUNE((n$1 != null), true); [line 21, column 3]\n " shape="invhouse"] +"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_6" [label="6: BinaryOperatorStmt: Assign \n *&item:NSArray*=n$3 [line 21, column 3]\n n$4=*&item:NSArray* [line 21, column 3]\n " shape="box"] - "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_6" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_9" ; -"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_7" [label="7: Prune (false branch, while) \n PRUNE(!(n$1 != null), false); [line 21, column 3]\n " shape="invhouse"] + "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_6" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_7" ; + "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_6" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_8" ; +"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_7" [label="7: Prune (true branch, while) \n PRUNE(n$4, true); [line 21, column 3]\n " shape="invhouse"] - "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_7" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_3" ; -"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_8" [label="8: BinaryOperatorStmt: Assign \n n$2=*&items:NSArray* [line 21, column 25]\n n$3=_fun_NSArray.nextObject(n$2:NSArray*) virtual [line 21, column 3]\n *&item:NSArray*=n$3 [line 21, column 3]\n " shape="box"] + "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_7" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_9" ; +"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_8" [label="8: Prune (false branch, while) \n PRUNE(!n$4, false); [line 21, column 3]\n " shape="invhouse"] - "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_8" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_4" ; -"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_9" [label="9: BinaryOperatorStmt: AddAssign \n n$4=*&item:NSArray* [line 22, column 14]\n n$5=_fun_NSArray.count(n$4:NSArray*) [line 22, column 13]\n n$6=*&size:int [line 22, column 5]\n *&size:int=(n$6 + n$5) [line 22, column 5]\n " shape="box"] + "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_8" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_3" ; +"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_9" [label="9: BinaryOperatorStmt: AddAssign \n n$5=*&item:NSArray* [line 22, column 14]\n n$6=_fun_NSArray.count(n$5:NSArray*) [line 22, column 13]\n n$7=*&size:int [line 22, column 5]\n *&size:int=(n$7 + n$6) [line 22, column 5]\n " shape="box"] - "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_9" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_8" ; -"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_10" [label="10: BinaryOperatorStmt: Assign \n n$8=*&items:NSArray* [line 21, column 25]\n n$9=_fun_NSArray.nextObject(n$8:NSArray*) virtual [line 21, column 3]\n *&item:NSArray*=n$9 [line 21, column 3]\n " shape="box"] + "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_9" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_4" ; +"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_10" [label="10: Message Call: objectEnumerator \n n$9=*&items:NSArray* [line 21, column 25]\n n$10=_fun_NSArray.objectEnumerator(n$9:NSArray*) virtual [line 21, column 3]\n " shape="box"] - "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_10" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_4" ; -"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_11" [label="11: DeclStmt \n VARIABLE_DECLARED(size:int); [line 20, column 3]\n *&size:int=0 [line 20, column 3]\n " shape="box"] + "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_10" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_11" ; +"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_11" [label="11: DeclStmt \n VARIABLE_DECLARED(0$?%__sil_tmp__enumerator_n$1:NSEnumerator*); [line 21, column 3]\n *&0$?%__sil_tmp__enumerator_n$1:NSEnumerator*=n$10 [line 21, column 3]\n " shape="box"] - "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_11" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_10" ; -"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_1" [label="1: Start A.fast_loop_no_crash\nFormals: self:A*\nLocals: obj:objc_object* \n " color=yellow style=filled] + "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_11" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_4" ; +"fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_12" [label="12: DeclStmt \n VARIABLE_DECLARED(size:int); [line 20, column 3]\n *&size:int=0 [line 20, column 3]\n " shape="box"] - "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_1" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_10" ; + "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_12" -> "fast_loop:#A(class NSArray)#instance.26b39d1106e4365a40bc2f6305401611_10" ; +"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_1" [label="1: Start A.fast_loop_no_crash\nFormals: self:A*\nLocals: 0$?%__sil_tmp__enumerator_n$19:NSEnumerator* obj:objc_object* \n " color=yellow style=filled] + + + "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_1" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_11" ; "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_2" [label="2: Exit A.fast_loop_no_crash \n " color=yellow style=filled] @@ -66,35 +70,39 @@ digraph cfg { "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_3" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_4" ; -"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_4" [label="4: BinaryOperatorStmt: NE \n n$18=*&obj:objc_object* [line 38, column 3]\n " shape="box"] +"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_4" [label="4: Message Call: nextObject \n n$20=*&0$?%__sil_tmp__enumerator_n$19:NSEnumerator* [line 38, column 3]\n n$21=_fun_NSEnumerator.nextObject(n$20:NSEnumerator*) virtual [line 38, column 3]\n " shape="box"] "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_4" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_5" ; - "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_4" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_6" ; -"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_5" [label="5: Prune (true branch, while) \n PRUNE((n$18 != null), true); [line 38, column 3]\n " shape="invhouse"] +"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_5" [label="5: BinaryOperatorStmt: Assign \n *&obj:objc_object*=n$21 [line 38, column 3]\n n$22=*&obj:objc_object* [line 38, column 3]\n " shape="box"] + + + "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_5" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_6" ; + "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_5" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_7" ; +"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_6" [label="6: Prune (true branch, while) \n PRUNE(n$22, true); [line 38, column 3]\n " shape="invhouse"] - "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_5" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_8" ; -"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_6" [label="6: Prune (false branch, while) \n PRUNE(!(n$18 != null), false); [line 38, column 3]\n " shape="invhouse"] + "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_6" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_8" ; +"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_7" [label="7: Prune (false branch, while) \n PRUNE(!n$22, false); [line 38, column 3]\n " shape="invhouse"] - "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_6" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_2" ; -"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_7" [label="7: BinaryOperatorStmt: Assign \n n$19=*&self:A* [line 38, column 15]\n n$20=*n$19.reverseObjectEnumerator:NSEnumerator* [line 38, column 15]\n n$21=_fun_NSEnumerator.nextObject(n$20:NSEnumerator*) virtual [line 38, column 3]\n *&obj:objc_object*=n$21 [line 38, column 3]\n " shape="box"] + "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_7" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_2" ; +"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_8" [label="8: Message Call: copy \n n$23=*&obj:objc_object* [line 39, column 6]\n n$24=_fun_NSObject.copy(n$23:objc_object*) virtual [line 39, column 5]\n " shape="box"] - "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_7" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_3" ; -"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_8" [label="8: Message Call: copy \n n$22=*&obj:objc_object* [line 39, column 6]\n n$23=_fun_NSObject.copy(n$22:objc_object*) virtual [line 39, column 5]\n " shape="box"] + "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_8" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_3" ; +"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_9" [label="9: Message Call: objectEnumerator \n n$26=*&self:A* [line 38, column 15]\n n$27=*n$26.reverseObjectEnumerator:NSEnumerator* [line 38, column 15]\n n$28=_fun_NSEnumerator.objectEnumerator(n$27:NSEnumerator*) virtual [line 38, column 3]\n " shape="box"] - "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_8" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_7" ; -"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_9" [label="9: BinaryOperatorStmt: Assign \n n$25=*&self:A* [line 38, column 15]\n n$26=*n$25.reverseObjectEnumerator:NSEnumerator* [line 38, column 15]\n n$27=_fun_NSEnumerator.nextObject(n$26:NSEnumerator*) virtual [line 38, column 3]\n *&obj:objc_object*=n$27 [line 38, column 3]\n " shape="box"] + "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_9" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_10" ; +"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_10" [label="10: DeclStmt \n VARIABLE_DECLARED(0$?%__sil_tmp__enumerator_n$19:NSEnumerator*); [line 38, column 3]\n *&0$?%__sil_tmp__enumerator_n$19:NSEnumerator*=n$28 [line 38, column 3]\n " shape="box"] - "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_9" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_3" ; -"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_10" [label="10: DeclStmt \n VARIABLE_DECLARED(obj:objc_object*); [line 37, column 3]\n *&obj:objc_object*=null [line 37, column 3]\n " shape="box"] + "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_10" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_3" ; +"fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_11" [label="11: DeclStmt \n VARIABLE_DECLARED(obj:objc_object*); [line 37, column 3]\n *&obj:objc_object*=null [line 37, column 3]\n " shape="box"] - "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_10" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_9" ; + "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_11" -> "fast_loop_no_crash#A#instance.eaee56a1051009329a3989c3a10fb432_9" ; "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_1" [label="1: Start A.while_loop:\nFormals: self:A* items:NSArray*\nLocals: item:NSArray* size:int \n " color=yellow style=filled] @@ -102,7 +110,7 @@ digraph cfg { "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_2" [label="2: Exit A.while_loop: \n " color=yellow style=filled] -"while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_3" [label="3: Return Stmt \n n$10=*&size:int [line 33, column 10]\n *&return:int=n$10 [line 33, column 3]\n " shape="box"] +"while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_3" [label="3: Return Stmt \n n$11=*&size:int [line 33, column 10]\n *&return:int=n$11 [line 33, column 3]\n " shape="box"] "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_3" -> "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_2" ; @@ -110,20 +118,20 @@ digraph cfg { "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_4" -> "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_5" ; -"while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_5" [label="5: BinaryOperatorStmt: Assign \n n$11=*&items:NSArray* [line 30, column 19]\n n$12=_fun_NSArray.objectAtIndex:(n$11:NSArray*,(unsigned long)3:unsigned long) virtual [line 30, column 18]\n *&item:NSArray*=n$12 [line 30, column 11]\n n$13=*&item:NSArray* [line 30, column 11]\n " shape="box"] +"while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_5" [label="5: BinaryOperatorStmt: Assign \n n$12=*&items:NSArray* [line 30, column 19]\n n$13=_fun_NSArray.objectAtIndex:(n$12:NSArray*,(unsigned long)3:unsigned long) virtual [line 30, column 18]\n *&item:NSArray*=n$13 [line 30, column 11]\n n$14=*&item:NSArray* [line 30, column 11]\n " shape="box"] "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_5" -> "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_6" ; "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_5" -> "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_7" ; -"while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_6" [label="6: Prune (true branch, while) \n PRUNE(n$13, true); [line 30, column 11]\n " shape="invhouse"] +"while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_6" [label="6: Prune (true branch, while) \n PRUNE(n$14, true); [line 30, column 11]\n " shape="invhouse"] "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_6" -> "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_8" ; -"while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_7" [label="7: Prune (false branch, while) \n PRUNE(!n$13, false); [line 30, column 11]\n " shape="invhouse"] +"while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_7" [label="7: Prune (false branch, while) \n PRUNE(!n$14, false); [line 30, column 11]\n " shape="invhouse"] "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_7" -> "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_3" ; -"while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_8" [label="8: BinaryOperatorStmt: AddAssign \n n$14=*&item:NSArray* [line 31, column 14]\n n$15=_fun_NSArray.count(n$14:NSArray*) [line 31, column 13]\n n$16=*&size:int [line 31, column 5]\n *&size:int=(n$16 + n$15) [line 31, column 5]\n " shape="box"] +"while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_8" [label="8: BinaryOperatorStmt: AddAssign \n n$15=*&item:NSArray* [line 31, column 14]\n n$16=_fun_NSArray.count(n$15:NSArray*) [line 31, column 13]\n n$17=*&size:int [line 31, column 5]\n *&size:int=(n$17 + n$16) [line 31, column 5]\n " shape="box"] "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_8" -> "while_loop:#A(class NSArray)#instance.225f55f19f886cfaa14fc056eca2399b_4" ; diff --git a/infer/tests/codetoanalyze/objc/performance/issues.exp b/infer/tests/codetoanalyze/objc/performance/issues.exp index 491154fa1..261da0af9 100644 --- a/infer/tests/codetoanalyze/objc/performance/issues.exp +++ b/infer/tests/codetoanalyze/objc/performance/issues.exp @@ -6,8 +6,8 @@ codetoanalyze/objc/performance/NSArray.m, nsarray_init_with_array_copy_linear_FP codetoanalyze/objc/performance/NSArray.m, nsarray_init_with_array_copy_linear_FP, 2, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [,Assignment,Binary operation: ([0, +oo] + 1):signed32] codetoanalyze/objc/performance/NSArray.m, nsarray_init_with_array_linear_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop] codetoanalyze/objc/performance/NSArray.m, nsarray_init_with_array_linear_FP, 3, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [,Assignment,Binary operation: ([0, +oo] + 1):signed32] -codetoanalyze/objc/performance/NSArray.m, nsarray_iterate_linear_FN, 3, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [,Assignment,,Unknown value from: NSArray.nextObject,Assignment,Binary operation: ([-oo, +oo] + [-oo, +oo]):signed64] -codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_enumerate_constant, 6, BUFFER_OVERRUN_U5, no_bucket, ERROR, [,Unknown value from: NSDictionary.nextObject,Assignment,,Unknown value from: NSDictionary.dictionaryWithObjects:forKeys:count:,Assignment,Array access: Offset: [-oo, +oo] (⇐ [-oo, +oo] + [-oo, +oo]) Size: [0, +oo]] +codetoanalyze/objc/performance/NSArray.m, nsarray_iterate_linear_FN, 3, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [,Assignment,,Unknown value from: NSEnumerator.nextObject,Assignment,Binary operation: ([-oo, +oo] + [-oo, +oo]):signed64] +codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_enumerate_constant, 6, BUFFER_OVERRUN_U5, no_bucket, ERROR, [,Unknown value from: NSEnumerator.nextObject,Assignment,,Unknown value from: NSDictionary.dictionaryWithObjects:forKeys:count:,Assignment,Array access: Offset: [-oo, +oo] (⇐ [-oo, +oo] + [-oo, +oo]) Size: [0, +oo]] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_with_dictionary_linear_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_with_dictionary_linear_FP, 2, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [,Assignment,Binary operation: ([0, +oo] + 1):signed32] codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_add_in_loop_constant, 5, CONDITION_ALWAYS_FALSE, no_bucket, WARNING, [Here] @@ -27,7 +27,7 @@ codetoanalyze/objc/performance/NSString.m, init_with_string_linear_FP, 0, INFINI codetoanalyze/objc/performance/NSString.m, init_with_string_linear_FP, 2, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [,Unknown value from: NSString.initWithString:,Binary operation: ([0, +oo] + 1):signed32] codetoanalyze/objc/performance/NSString.m, replace_linear_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop] codetoanalyze/objc/performance/NSString.m, replace_linear_FP, 2, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [,Unknown value from: NSString.stringByReplacingOccurrencesOfString:withString:,Binary operation: ([0, +oo] + 1):signed32] -codetoanalyze/objc/performance/block.m, objc_blockblock_multiply_array_linear_FN_1, 3, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [,Assignment,,Unknown value from: NSArray.nextObject,Assignment,Binary operation: ([-oo, +oo] + [-oo, +oo]):signed64] +codetoanalyze/objc/performance/block.m, objc_blockblock_multiply_array_linear_FN_1, 3, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [,Assignment,,Unknown value from: NSEnumerator.nextObject,Assignment,Binary operation: ([-oo, +oo] + [-oo, +oo]):signed64] codetoanalyze/objc/performance/compound_loop_guard.m, compound_while, 3, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here] codetoanalyze/objc/performance/compound_loop_guard.m, nested_while_and_or_constant, 3, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here] codetoanalyze/objc/performance/compound_loop_guard.m, nested_while_and_or_constant, 3, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here]