[clang] Using dumped info from array and dict literals

Reviewed By: jvillard

Differential Revision: D8542227

fbshipit-source-id: 75ccf62
master
Dulma Churchill 7 years ago committed by Facebook Github Bot
parent 4c726692a9
commit 93ffa826a7

@ -1 +1 @@
Subproject commit a207409847b6d09e610776b113cd922621e96ed7 Subproject commit 10eb1ac9bb9e94ae8332e84058f39699422a0e85

@ -84,10 +84,8 @@ let __objc_alloc_no_fail = create_procname "__objc_alloc_no_fail"
let __objc_cast = create_procname "__objc_cast" let __objc_cast = create_procname "__objc_cast"
(* We don't need to add parameters to this one because it is used to translate dictionary literals
and the actual method doesn't appear in the AST, instead we create the corresponding AST bit in cTrans. *)
let __objc_dictionary_literal = let __objc_dictionary_literal =
create_objc_class_method "NSDictionary" "dictionaryWithObjects:forKeys:count:" [] create_objc_class_method "NSDictionary" "dictionaryWithObjects:forKeys:count:" [None; None; None]
let __placement_delete = create_procname "__placement_delete" let __placement_delete = create_procname "__placement_delete"
@ -141,9 +139,9 @@ let nsArray_arrayWithObjects =
create_objc_class_method "NSArray" "arrayWithObjects:" [Some objc_object] create_objc_class_method "NSArray" "arrayWithObjects:" [Some objc_object]
(* We don't need to add parameters to this one because it is used to translate array literals let nsArray_arrayWithObjectsCount =
and the actual method doesn't appear in the AST, instead we create the corresponding AST bit in cTrans. *) create_objc_class_method "NSArray" "arrayWithObjects:count:" [None; None]
let nsArray_arrayWithObjectsCount = create_objc_class_method "NSArray" "arrayWithObjects:count:" []
let objc_cpp_throw = create_procname "__infer_objc_cpp_throw" let objc_cpp_throw = create_procname "__infer_objc_cpp_throw"

@ -44,8 +44,6 @@ exception Invalid_declaration
let alloc = "alloc" let alloc = "alloc"
let array_with_objects_count_m = "arrayWithObjects:count:"
let assert_fail = "__assert_fail" let assert_fail = "__assert_fail"
let assert_rtn = "__assert_rtn" let assert_rtn = "__assert_rtn"

@ -45,8 +45,6 @@ exception Invalid_declaration
val alloc : string val alloc : string
val array_with_objects_count_m : string
val assert_fail : string val assert_fail : string
val assert_rtn : string val assert_rtn : string

@ -2566,34 +2566,40 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
instruction trans_state message_stmt instruction trans_state message_stmt
and objCArrayLiteral_trans trans_state info stmt_info stmts = and objCArrayDictLiteral_trans trans_state expr_info stmt_info stmts method_pointer =
let typ = let open Clang_ast_t in
CType_decl.class_from_pointer_type trans_state.context.CContext.tenv match CAst_utils.get_decl_opt method_pointer with
info.Clang_ast_t.ei_qual_type | Some (ObjCMethodDecl (decl_info, named_decl_info, _)) ->
in let typ =
let meth = CFrontend_config.array_with_objects_count_m in CAst_utils.qual_type_of_decl_ptr (Option.value_exn decl_info.di_parent_pointer)
let obj_c_mes_expr_info = Ast_expressions.make_obj_c_message_expr_info_class meth typ None in in
let obj_c_mes_expr_info =
{ Clang_ast_t.omei_selector= named_decl_info.Clang_ast_t.ni_name
; omei_receiver_kind= `Class typ
; omei_is_definition_found= true
; omei_decl_pointer= method_pointer }
in
let message_stmt =
Clang_ast_t.ObjCMessageExpr (stmt_info, stmts, expr_info, obj_c_mes_expr_info)
in
instruction trans_state message_stmt
| _ ->
Logging.die InternalError
"The method for translating array/dictionary literals is not available at %s"
(Clang_ast_j.string_of_stmt_info stmt_info)
and objCArrayLiteral_trans trans_state expr_info stmt_info stmts array_literal_info =
let method_pointer = array_literal_info.Clang_ast_t.oalei_array_method in
let stmts = stmts @ [Ast_expressions.create_nil stmt_info] in let stmts = stmts @ [Ast_expressions.create_nil stmt_info] in
let message_stmt = Clang_ast_t.ObjCMessageExpr (stmt_info, stmts, info, obj_c_mes_expr_info) in objCArrayDictLiteral_trans trans_state expr_info stmt_info stmts method_pointer
instruction trans_state message_stmt
and objCDictionaryLiteral_trans trans_state info stmt_info stmts = and objCDictionaryLiteral_trans trans_state expr_info stmt_info stmts dict_literal_info =
let typ = let method_pointer = dict_literal_info.Clang_ast_t.odlei_dict_method in
CType_decl.class_from_pointer_type trans_state.context.CContext.tenv
info.Clang_ast_t.ei_qual_type
in
let dictionary_literal_pname = BuiltinDecl.__objc_dictionary_literal in
let dictionary_literal_s = Typ.Procname.get_method dictionary_literal_pname in
let obj_c_message_expr_info =
Ast_expressions.make_obj_c_message_expr_info_class dictionary_literal_s typ None
in
let stmts = CGeneral_utils.swap_elements_list stmts in let stmts = CGeneral_utils.swap_elements_list stmts in
let stmts = stmts @ [Ast_expressions.create_nil stmt_info] in let stmts = stmts @ [Ast_expressions.create_nil stmt_info] in
let message_stmt = objCArrayDictLiteral_trans trans_state expr_info stmt_info stmts method_pointer
Clang_ast_t.ObjCMessageExpr (stmt_info, stmts, info, obj_c_message_expr_info)
in
instruction trans_state message_stmt
and objCStringLiteral_trans trans_state stmt_info stmts info = and objCStringLiteral_trans trans_state stmt_info stmts info =
@ -3283,10 +3289,10 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
objCBoxedExpr_trans trans_state info sel stmt_info stmts objCBoxedExpr_trans trans_state info sel stmt_info stmts
| None -> | None ->
assert false ) assert false )
| ObjCArrayLiteral (stmt_info, stmts, info) -> | ObjCArrayLiteral (stmt_info, stmts, expr_info, array_literal_info) ->
objCArrayLiteral_trans trans_state info stmt_info stmts objCArrayLiteral_trans trans_state expr_info stmt_info stmts array_literal_info
| ObjCDictionaryLiteral (stmt_info, stmts, info) -> | ObjCDictionaryLiteral (stmt_info, stmts, expr_info, dict_literal_info) ->
objCDictionaryLiteral_trans trans_state info stmt_info stmts objCDictionaryLiteral_trans trans_state expr_info stmt_info stmts dict_literal_info
| ObjCStringLiteral (stmt_info, stmts, info) -> | ObjCStringLiteral (stmt_info, stmts, info) ->
objCStringLiteral_trans trans_state stmt_info stmts info objCStringLiteral_trans trans_state stmt_info stmts info
| BreakStmt (stmt_info, _) -> | BreakStmt (stmt_info, _) ->

Loading…
Cancel
Save