Update fcp to include recent changes

Summary:
Update fcp version and make infer build with it.
It's not using new features yet, diffs will follow.

New stuff:
Proper type information in form of pointer->type
Expose more information about cxx classes (superclass info)
Add pointers to objc method decls when possible
master
Andrzej Kotulski 10 years ago
parent be640f9c4e
commit 7409d48305

@ -1 +1 @@
c4197d9f677a129304711a82c1f2e0fda4952314
85c810aa245fdbd34687b17ec5a8214db2016bcb

@ -83,7 +83,9 @@ let stmt_info_with_fresh_pointer stmt_info =
let create_qual_type s =
{
Clang_ast_t.qt_raw = s;
Clang_ast_t.qt_desugared = Some s
Clang_ast_t.qt_desugared = Some s;
(* pointer needs to be set when we start using these, non trivial to do though *)
Clang_ast_t.qt_type_ptr = Ast_utils.get_invalid_pointer ()
}
let create_pointer_type s =
@ -97,7 +99,8 @@ let create_id_type () = create_qual_type "id"
let create_char_type () = create_qual_type "char *"
let create_BOOL_type () = { qt_raw = "BOOL"; qt_desugared = Some("signed char") }
(* pointer needs to be set when we start using these, non trivial to do though *)
let create_BOOL_type () = { qt_raw = "BOOL"; qt_desugared = Some("signed char"); qt_type_ptr = Ast_utils.get_invalid_pointer () }
let create_void_unsigned_long_type () = create_qual_type "void *(unsigned long)"
@ -194,13 +197,15 @@ let make_decl_ref_exp stmt_info expr_info drei =
let make_obj_c_message_expr_info_instance sel =
{
Clang_ast_t.omei_selector = sel;
Clang_ast_t.omei_receiver_kind = `Instance
Clang_ast_t.omei_receiver_kind = `Instance;
Clang_ast_t.omei_decl_pointer = None (* TODO look into it *)
}
let make_obj_c_message_expr_info_class selector qt =
{
omei_selector = selector;
omei_receiver_kind = `Class (create_qual_type qt);
Clang_ast_t.omei_decl_pointer = None (* TODO look into it *)
}
let make_name_decl name = {
@ -553,7 +558,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei =
let objc_sre = ObjCSubscriptRefExpr((fresh_stmt_info stmt_info), [ove_array; ove_idx],
make_expr_info (pseudo_object_qt ()),
{ osrei_kind =`ArraySubscript; osrei_getter = None; osrei_setter = None; }) in
let obj_c_message_expr_info = { omei_selector = CFrontend_config.object_at_indexed_subscript_m; omei_receiver_kind =`Instance } in
let obj_c_message_expr_info = { omei_selector = CFrontend_config.object_at_indexed_subscript_m; omei_receiver_kind =`Instance; omei_decl_pointer = None} in
let ome = ObjCMessageExpr((fresh_stmt_info stmt_info), [ove_array; ove_idx], poe_ei, obj_c_message_expr_info) in
let pseudo_obj_expr = PseudoObjectExpr((fresh_stmt_info stmt_info), [objc_sre; ove_array; ove_idx; ome], poe_ei) in
let vdi = { empty_var_decl_info with vdi_init_expr = Some (pseudo_obj_expr) } in

@ -20,14 +20,14 @@ module F = Format
(** Get the sub-declarations of the current declaration. *)
let decl_get_sub_decls decl = match decl with
| CXXRecordDecl (_, _, _, decl_list, _, _)
| RecordDecl (_, _, _, decl_list, _, _)
| CXXRecordDecl (_, _, _, _, decl_list, _, _, _)
| RecordDecl (_, _, _, _, decl_list, _, _)
| ObjCInterfaceDecl (_, _, decl_list, _, _)
| ObjCProtocolDecl (_, _, decl_list, _, _)
| ObjCCategoryDecl (_, _, decl_list, _, _)
| ObjCCategoryImplDecl (_, _, decl_list, _, _)
| ObjCImplementationDecl (_, _, decl_list, _, _)
| EnumDecl (_, _, _, decl_list, _, _)
| EnumDecl (_, _, _, _, decl_list, _, _)
| LinkageSpecDecl (_, decl_list, _)
| NamespaceDecl (_, _, decl_list, _, _) ->
decl_list
@ -37,10 +37,10 @@ let decl_get_sub_decls decl = match decl with
(** Set the sub-declarations of the current declaration. *)
let decl_set_sub_decls decl decl_list' = match decl with
| CXXRecordDecl (decl_info, name, opt_type, decl_list, decl_context_info, record_decl_info) ->
CXXRecordDecl (decl_info, name, opt_type, decl_list', decl_context_info, record_decl_info)
| RecordDecl (decl_info, name, opt_type, decl_list, decl_context_info, record_decl_info) ->
RecordDecl (decl_info, name, opt_type, decl_list', decl_context_info, record_decl_info)
| CXXRecordDecl (decl_info, name, opt_type, type_ptr, decl_list, decl_context_info, record_decl_info, cxx_record_info) ->
CXXRecordDecl (decl_info, name, opt_type, type_ptr, decl_list', decl_context_info, record_decl_info, cxx_record_info)
| RecordDecl (decl_info, name, opt_type, type_ptr, decl_list, decl_context_info, record_decl_info) ->
RecordDecl (decl_info, name, opt_type, type_ptr, decl_list', decl_context_info, record_decl_info)
| ObjCInterfaceDecl (decl_info, name, decl_list, decl_context_info, obj_c_interface_decl_info) ->
ObjCInterfaceDecl (decl_info, name, decl_list', decl_context_info, obj_c_interface_decl_info)
| ObjCProtocolDecl (decl_info, name, decl_list, decl_context_info, obj_c_protocol_decl_info) ->
@ -51,8 +51,8 @@ let decl_set_sub_decls decl decl_list' = match decl with
ObjCCategoryImplDecl (decl_info, name, decl_list', decl_context_info, category_impl_info)
| ObjCImplementationDecl (decl_info, class_name, decl_list, decl_context_info, idi) ->
ObjCImplementationDecl (decl_info, class_name, decl_list', decl_context_info, idi)
| EnumDecl (decl_info, name, opt_type, decl_list, decl_context_info, enum_decl_info) ->
EnumDecl (decl_info, name, opt_type, decl_list', decl_context_info, enum_decl_info)
| EnumDecl (decl_info, name, opt_type, type_ptr, decl_list, decl_context_info, enum_decl_info) ->
EnumDecl (decl_info, name, opt_type, type_ptr, decl_list', decl_context_info, enum_decl_info)
| LinkageSpecDecl (decl_info, decl_list, decl_context_info) ->
LinkageSpecDecl (decl_info, decl_list', decl_context_info)
| NamespaceDecl (decl_info, name, decl_list, decl_context_info, namespace_decl_info) ->
@ -131,7 +131,7 @@ let pp_ast_decl fmt ast_decl =
let decl_str = Clang_ast_proj.get_decl_kind_string ast_decl in
match ast_decl with
| TranslationUnitDecl (_, decl_list, _) ->
| TranslationUnitDecl (_, decl_list, _, _) ->
F.fprintf fmt "%s (%d declarations)@\n" decl_str (list_length decl_list);
list_iter (dump_decl "") decl_list
| _ ->
@ -282,9 +282,9 @@ let ast_decl_process_locs loc_composer ast_decl =
decl_process_locs loc_composer decl in
match ast_decl with
| TranslationUnitDecl (decl_info, decl_list, decl_context_info) ->
| TranslationUnitDecl (decl_info, decl_list, decl_context_info, type_list) ->
let decl_list' = list_map toplevel_decl_process_locs decl_list in
TranslationUnitDecl (decl_info, decl_list', decl_context_info)
TranslationUnitDecl (decl_info, decl_list', decl_context_info, type_list)
| _ ->
assert false

@ -31,13 +31,13 @@ let rec translate_one_declaration tenv cg cfg namespace dec =
| FunctionDecl(di, name_info, qt, fdecl_info) ->
let name = name_info.Clang_ast_t.ni_name in
CMethod_declImpl.function_decl tenv cfg cg namespace false di name qt fdecl_info [] None CContext.ContextNoCls
| TypedefDecl (decl_info, name_info, opt_type, typedef_decl_info) ->
| TypedefDecl (decl_info, name_info, opt_type, _, typedef_decl_info) ->
let name = name_info.Clang_ast_t.ni_name in
CTypes_decl.do_typedef_declaration tenv namespace
decl_info name opt_type typedef_decl_info
(* Currently C/C++ record decl treated in the same way *)
| CXXRecordDecl (decl_info, name_info, opt_type, decl_list, decl_context_info, record_decl_info)
| RecordDecl (decl_info, name_info, opt_type, decl_list, decl_context_info, record_decl_info) ->
| CXXRecordDecl (decl_info, name_info, opt_type, _, decl_list, decl_context_info, record_decl_info, _)
| RecordDecl (decl_info, name_info, opt_type, _, decl_list, decl_context_info, record_decl_info) ->
let record_name = name_info.Clang_ast_t.ni_name in
CTypes_decl.do_record_declaration tenv namespace
decl_info record_name opt_type decl_list decl_context_info record_decl_info
@ -75,7 +75,7 @@ let rec translate_one_declaration tenv cg cfg namespace dec =
ObjcInterface_decl.interface_impl_declaration tenv name decl_list idi in
CMethod_declImpl.process_methods tenv cg cfg curr_class namespace decl_list
| EnumDecl(decl_info, name_info, opt_type, decl_list, decl_context_info, enum_decl_info)
| EnumDecl(decl_info, name_info, opt_type, _, decl_list, decl_context_info, enum_decl_info)
when should_translate_enum ->
let name = name_info.Clang_ast_t.ni_name in
CEnum_decl.enum_decl name tenv cfg cg namespace decl_list opt_type
@ -104,7 +104,7 @@ let preprocess_one_declaration tenv cg cfg dec =
(* Translates a file by translating the ast into a cfg. *)
let compute_icfg tenv source_file ast =
match ast with
| TranslationUnitDecl(_, decl_list, _) ->
| TranslationUnitDecl(_, decl_list, _, _) ->
CFrontend_config.global_translation_unit_decls:= decl_list;
Printing.log_out "\n Start creating icfg\n";
let cg = Cg.create () in

@ -108,7 +108,8 @@ let do_run source_path ast_path =
Printing.log_out "Original AST@.%a@." CAstProcessor.pp_ast_decl ast_decl;
Printing.log_out "AST with explicit locations:@.%a@." CAstProcessor.pp_ast_decl ast_decl';
CFrontend_config.pointer_decl_index := Clang_ast_main.index_decl_pointers ast_decl';
let decl_index, _ = Clang_ast_main.index_decl_type_pointers ast_decl' in
CFrontend_config.pointer_decl_index := decl_index;
CFrontend_config.json := ast_filename;
CLocation.check_source_file source_path;
let source_file = CLocation.source_file_from_path source_path in

@ -188,10 +188,10 @@ and get_struct_fields tenv record_name namespace decl_list =
let typ = qual_type_to_sil_type tenv qual_type in
let annotation_items = [] in (* For the moment we don't use them*)
(id, typ, annotation_items):: get_struct_fields tenv record_name namespace decl_list'
| CXXRecordDecl (decl_info, name, opt_type, decl_list, decl_context_info, record_decl_info)
| CXXRecordDecl (decl_info, name, opt_type, _, decl_list, decl_context_info, record_decl_info, _)
:: decl_list'
(* C++/C Records treated in the same way*)
| RecordDecl (decl_info, name, opt_type, decl_list, decl_context_info, record_decl_info)
| RecordDecl (decl_info, name, opt_type, _, decl_list, decl_context_info, record_decl_info)
:: decl_list'->
do_record_declaration tenv namespace decl_info name.Clang_ast_t.ni_name opt_type decl_list decl_context_info record_decl_info;
get_struct_fields tenv record_name namespace decl_list'
@ -246,10 +246,10 @@ and add_late_defined_record tenv namespace typename =
match decls with
| [] -> false
| CXXRecordDecl
(decl_info, record_name, opt_type, decl_list, decl_context_info, record_decl_info)
(decl_info, record_name, opt_type, _, decl_list, decl_context_info, record_decl_info, _)
:: decls'
| RecordDecl
(decl_info, record_name, opt_type, decl_list, decl_context_info, record_decl_info)
(decl_info, record_name, opt_type, _, decl_list, decl_context_info, record_decl_info)
:: decls' ->
(match opt_type with
| `Type t ->
@ -280,7 +280,7 @@ and add_late_defined_typedef tenv namespace typename =
let rec scan decls =
match decls with
| [] -> false
| TypedefDecl (decl_info, name_info, opt_type, tdi) :: decls' ->
| TypedefDecl (decl_info, name_info, opt_type, _, tdi) :: decls' ->
let name' = name_info.Clang_ast_t.ni_name in
(match opt_type with
| `Type t ->

@ -156,12 +156,12 @@ and get_variables_decls context (decl_list : Clang_ast_t.decl list) : unit =
| _ ->
CContext.LocalVars.add_local_var context name typ decl_info.Clang_ast_t.di_pointer
(CFrontend_utils.General_utils.is_static_var var_decl_info))
| CXXRecordDecl(di, n_info, ot, dl, dci, rdi)
| RecordDecl(di, n_info, ot, dl, dci, rdi) ->
| CXXRecordDecl(di, n_info, ot, _, dl, dci, rdi, _)
| RecordDecl(di, n_info, ot, _, dl, dci, rdi) ->
let typ = CTypes_decl.get_declaration_type context.CContext.tenv context.CContext.namespace
di n_info.Clang_ast_t.ni_name ot dl dci rdi in
CTypes_decl.add_struct_to_tenv context.CContext.tenv typ
| TypedefDecl (decl_info, name_info, opt_type, typedef_decl_info) ->
| TypedefDecl (decl_info, name_info, opt_type, _, typedef_decl_info) ->
CTypes_decl.do_typedef_declaration context.CContext.tenv context.CContext.namespace
decl_info name_info.Clang_ast_t.ni_name opt_type typedef_decl_info
| StaticAssertDecl decl_info -> (* We do not treat Assertions. *)

Loading…
Cancel
Save