From 16604a9e75715060682111688796fa91be92edcb Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Thu, 1 Oct 2015 06:07:56 -0700 Subject: [PATCH] Update fcp which exports less redundant information MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: @​public We no longer rely on existence of qt_raw field. Update facebook-clang-plugins so that this field is not even exported. This should give us some perf wins since qual_type is written in a lot of places Reviewed By: @dulmarod Differential Revision: D2489308 --- facebook-clang-plugins | 2 +- infer/src/clang/ast_expressions.ml | 34 ++++------------------------ infer/src/clang/cFrontend_utils.ml | 4 ++-- infer/src/clang/cType_to_sil_type.ml | 2 +- infer/src/clang/cTypes.ml | 9 ++------ infer/src/clang/cTypes_decl.ml | 6 ++--- 6 files changed, 14 insertions(+), 43 deletions(-) diff --git a/facebook-clang-plugins b/facebook-clang-plugins index 7448f0c1a..52b5fd8f3 160000 --- a/facebook-clang-plugins +++ b/facebook-clang-plugins @@ -1 +1 @@ -Subproject commit 7448f0c1a80b1a6f8a2e826c3acafc3df7f9621e +Subproject commit 52b5fd8f3c171c2782f243532fd316236e6a0348 diff --git a/infer/src/clang/ast_expressions.ml b/infer/src/clang/ast_expressions.ml index b1a490c29..b56dd5ba9 100644 --- a/infer/src/clang/ast_expressions.ml +++ b/infer/src/clang/ast_expressions.ml @@ -76,20 +76,11 @@ let stmt_info_with_fresh_pointer stmt_info = { si_source_range = stmt_info.Clang_ast_t.si_source_range; } -let create_qual_type_with_just_pointer pointer = - { - Clang_ast_t.qt_raw = ""; - qt_desugared = None; - qt_type_ptr = pointer; - } +let create_qual_type_with_just_pointer pointer = pointer let get_constant_qual_type s = let pointer = CFrontend_config.type_pointer_prefix ^ s in - { - Clang_ast_t.qt_raw = ""; - qt_desugared = None; - qt_type_ptr = pointer - } + pointer (* Whenever new type are added manually to the translation here, *) (* they should be added to the map in cTypes_decl too!! *) @@ -123,26 +114,11 @@ let create_void_unsigned_long_type = let create_void_void_type = get_constant_qual_type "void (void *)" -let create_class_type class_name = - { - Clang_ast_t.qt_raw = ""; - qt_desugared = None; - qt_type_ptr = "custom_class_name*" ^ class_name; - } +let create_class_type class_name = "custom_class_name*" ^ class_name -let create_struct_type struct_name = - { - Clang_ast_t.qt_raw = ""; - qt_desugared = None; - qt_type_ptr = "custom_struct_name*" ^ struct_name; - } +let create_struct_type struct_name = "custom_struct_name*" ^ struct_name -let create_pointer_type class_type = - { - Clang_ast_t.qt_raw = ""; - qt_desugared = None; - qt_type_ptr = "custom_pointer_"^class_type.Clang_ast_t.qt_type_ptr - } +let create_pointer_type class_type = "custom_pointer_" ^ class_type let create_integer_literal stmt_info n = let stmt_info = dummy_stmt_info () in diff --git a/infer/src/clang/cFrontend_utils.ml b/infer/src/clang/cFrontend_utils.ml index 820e8b6f2..b4face3b5 100644 --- a/infer/src/clang/cFrontend_utils.ml +++ b/infer/src/clang/cFrontend_utils.ml @@ -314,12 +314,12 @@ struct (*TODO take the attributes into account too. To be done after we get the attribute's arguments. *) let is_type_nonnull qt attributes = let open Clang_ast_t in - match get_type qt.qt_type_ptr with + match get_type qt with | Some AttributedType (_, attr_info) -> attr_info.ati_attr_kind = `Nonnull | _ -> false let string_of_qual_type qt = - match get_desugared_type qt.Clang_ast_t.qt_type_ptr with + match get_desugared_type qt with | Some typ -> (Clang_ast_proj.get_type_tuple typ).Clang_ast_t.ti_raw | None -> "" diff --git a/infer/src/clang/cType_to_sil_type.ml b/infer/src/clang/cType_to_sil_type.ml index 240f18506..a0e8c89c0 100644 --- a/infer/src/clang/cType_to_sil_type.ml +++ b/infer/src/clang/cType_to_sil_type.ml @@ -170,7 +170,7 @@ and qual_type_ptr_to_sil_type translate_decl tenv type_ptr = | _ -> Sil.Tvoid and qual_type_to_sil_type translate_decl tenv qt = - let type_ptr = qt.Clang_ast_t.qt_type_ptr in + let type_ptr = qt in match custom_qual_type_to_sil_type type_ptr with | Some typ -> typ | None -> qual_type_ptr_to_sil_type translate_decl tenv type_ptr diff --git a/infer/src/clang/cTypes.ml b/infer/src/clang/cTypes.ml index f2f7103ca..9e7f19e7b 100644 --- a/infer/src/clang/cTypes.ml +++ b/infer/src/clang/cTypes.ml @@ -42,11 +42,6 @@ let lookup_var_type context pvar = (Sil.pvar_to_string pvar); Sil.Tvoid -let get_desugared_type t = - match t.Clang_ast_t.qt_desugared with - | Some t' -> t' - | _ -> assert false - let get_name_from_struct s = match s with | Sil.Tstruct(_, _, _, Some n, _, _, _) -> n @@ -127,11 +122,11 @@ let rec return_type_of_function_type_ptr type_ptr = "" let return_type_of_function_type qt = - return_type_of_function_type_ptr qt.Clang_ast_t.qt_type_ptr + return_type_of_function_type_ptr qt let is_block_type qt = let open Clang_ast_t in - match Ast_utils.get_desugared_type qt.Clang_ast_t.qt_type_ptr with + match Ast_utils.get_desugared_type qt with | Some BlockPointerType _ -> true | _ -> false diff --git a/infer/src/clang/cTypes_decl.ml b/infer/src/clang/cTypes_decl.ml index ffb23ad50..309549114 100644 --- a/infer/src/clang/cTypes_decl.ml +++ b/infer/src/clang/cTypes_decl.ml @@ -38,13 +38,13 @@ let add_predefined_basic_types tenv = let open Clang_ast_t in let add_basic_type qt basic_type_kind = let sil_type = CType_to_sil_type.sil_type_of_builtin_type_kind basic_type_kind in - Ast_utils.update_sil_types_map qt.Clang_ast_t.qt_type_ptr sil_type in + Ast_utils.update_sil_types_map qt sil_type in let add_pointer_type qt sil_type = let pointer_type = CTypes.add_pointer_to_typ sil_type in - Ast_utils.update_sil_types_map qt.Clang_ast_t.qt_type_ptr pointer_type in + Ast_utils.update_sil_types_map qt pointer_type in let add_function_type qt return_type = (* We translate function types as the return type of the function *) - Ast_utils.update_sil_types_map qt.Clang_ast_t.qt_type_ptr return_type in + Ast_utils.update_sil_types_map qt return_type in let sil_void_type = CType_to_sil_type.sil_type_of_builtin_type_kind `Void in let sil_char_type = CType_to_sil_type.sil_type_of_builtin_type_kind `Char_S in let sil_nsarray_type = Sil.Tvar (CTypes.mk_classname CFrontend_config.nsarray_cl) in