More inline records

Summary: Names are better than comments :)

Reviewed By: dulmarod

Differential Revision: D7194145

fbshipit-source-id: 4a8bc3c
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent 77e643ee1e
commit 279e7d67f0

@ -123,7 +123,7 @@ module T = struct
| Tint of ikind (** integer type *) | Tint of ikind (** integer type *)
| Tfloat of fkind (** float type *) | Tfloat of fkind (** float type *)
| Tvoid (** void type *) | Tvoid (** void type *)
| Tfun of bool (** function type with noreturn attribute *) | Tfun of {no_return: bool} (** function type with noreturn attribute *)
| Tptr of t * ptr_kind (** pointer type *) | Tptr of t * ptr_kind (** pointer type *)
| Tstruct of name (** structured value type name *) | Tstruct of name (** structured value type name *)
| TVar of string (** type variable (ie. C++ template variables) *) | TVar of string (** type variable (ie. C++ template variables) *)
@ -218,9 +218,9 @@ let rec pp_full pe f typ =
F.fprintf f "%s" (fkind_to_string fk) F.fprintf f "%s" (fkind_to_string fk)
| Tvoid -> | Tvoid ->
F.fprintf f "void" F.fprintf f "void"
| Tfun false -> | Tfun {no_return= false} ->
F.fprintf f "_fn_" F.fprintf f "_fn_"
| Tfun true -> | Tfun {no_return= true} ->
F.fprintf f "_fn_noreturn_" F.fprintf f "_fn_noreturn_"
| Tptr (({desc= Tarray _ | Tfun _} as typ), pk) -> | Tptr (({desc= Tarray _ | Tfun _} as typ), pk) ->
F.fprintf f "%a(%s)" (pp_full pe) typ (ptr_kind_string pk |> escape pe) F.fprintf f "%a(%s)" (pp_full pe) typ (ptr_kind_string pk |> escape pe)
@ -700,9 +700,9 @@ module Procname = struct
module ObjC_Cpp = struct module ObjC_Cpp = struct
type kind = type kind =
| CPPMethod of string option | CPPMethod of {mangled: string option}
| CPPConstructor of (string option * bool) | CPPConstructor of {mangled: string option; is_constexpr: bool}
| CPPDestructor of string option | CPPDestructor of {mangled: string option}
| ObjCClassMethod | ObjCClassMethod
| ObjCInstanceMethod | ObjCInstanceMethod
| ObjCInternalMethod | ObjCInternalMethod
@ -752,18 +752,18 @@ module Procname = struct
is_objc_dealloc name.method_name is_objc_dealloc name.method_name
let is_constexpr = function {kind= CPPConstructor (_, true)} -> true | _ -> false let is_constexpr = function {kind= CPPConstructor {is_constexpr= true}} -> true | _ -> false
let is_cpp_lambda {method_name} = String.is_substring ~substring:"operator()" method_name let is_cpp_lambda {method_name} = String.is_substring ~substring:"operator()" method_name
let is_operator_equal {method_name} = String.is_substring ~substring:"operator=" method_name let is_operator_equal {method_name} = String.is_substring ~substring:"operator=" method_name
let kind_to_verbose_string = function let kind_to_verbose_string = function
| CPPMethod m | CPPDestructor m -> | CPPMethod {mangled} | CPPDestructor {mangled} ->
"(" ^ (match m with None -> "" | Some s -> s) ^ ")" "(" ^ Option.value ~default:"" mangled ^ ")"
| CPPConstructor (m, is_constexpr) -> | CPPConstructor {mangled; is_constexpr} ->
"{" ^ (match m with None -> "" | Some s -> s) "{" ^ Option.value ~default:"" mangled ^ (if is_constexpr then "|constexpr" else "")
^ (if is_constexpr then "|constexpr" else "") ^ "}" ^ "}"
| ObjCClassMethod -> | ObjCClassMethod ->
"class" "class"
| ObjCInstanceMethod -> | ObjCInstanceMethod ->
@ -1127,9 +1127,10 @@ module Procname = struct
end end
module Fieldname = struct module Fieldname = struct
type clang_field_info = {class_name: Name.t; field_name: string} [@@deriving compare] type t =
| Clang of {class_name: Name.t; field_name: string}
type t = Clang of clang_field_info | Java of string [@@deriving compare] | Java of string
[@@deriving compare]
let equal = [%compare.equal : t] let equal = [%compare.equal : t]

@ -74,7 +74,7 @@ and desc =
| Tint of ikind (** integer type *) | Tint of ikind (** integer type *)
| Tfloat of fkind (** float type *) | Tfloat of fkind (** float type *)
| Tvoid (** void type *) | Tvoid (** void type *)
| Tfun of bool (** function type with noreturn attribute *) | Tfun of {no_return: bool} (** function type with noreturn attribute *)
| Tptr of t * ptr_kind (** pointer type *) | Tptr of t * ptr_kind (** pointer type *)
| Tstruct of name (** structured value type name *) | Tstruct of name (** structured value type name *)
| TVar of string (** type variable (ie. C++ template variables) *) | TVar of string (** type variable (ie. C++ template variables) *)
@ -339,9 +339,9 @@ module Procname : sig
module ObjC_Cpp : sig module ObjC_Cpp : sig
type kind = type kind =
| CPPMethod of string option (** with mangling *) | CPPMethod of {mangled: string option}
| CPPConstructor of (string option * bool) (** with mangling + is it constexpr? *) | CPPConstructor of {mangled: string option; is_constexpr: bool}
| CPPDestructor of string option (** with mangling *) | CPPDestructor of {mangled: string option}
| ObjCClassMethod | ObjCClassMethod
| ObjCInstanceMethod | ObjCInstanceMethod
| ObjCInternalMethod | ObjCInternalMethod

@ -105,11 +105,11 @@ let mk_cpp_method ?tenv class_name method_name ?meth_decl mangled =
let method_kind = let method_kind =
match meth_decl with match meth_decl with
| Some Clang_ast_t.CXXConstructorDecl (_, _, _, _, {xmdi_is_constexpr}) -> | Some Clang_ast_t.CXXConstructorDecl (_, _, _, _, {xmdi_is_constexpr}) ->
Typ.Procname.ObjC_Cpp.CPPConstructor (mangled, xmdi_is_constexpr) Typ.Procname.ObjC_Cpp.CPPConstructor {mangled; is_constexpr= xmdi_is_constexpr}
| Some Clang_ast_t.CXXDestructorDecl _ -> | Some Clang_ast_t.CXXDestructorDecl _ ->
Typ.Procname.ObjC_Cpp.CPPDestructor mangled Typ.Procname.ObjC_Cpp.CPPDestructor {mangled}
| _ -> | _ ->
Typ.Procname.ObjC_Cpp.CPPMethod mangled Typ.Procname.ObjC_Cpp.CPPMethod {mangled}
in in
let template_info, is_generic_model = let template_info, is_generic_model =
match meth_decl with match meth_decl with

@ -131,7 +131,7 @@ and type_desc_of_c_type translate_decl tenv c_type : Typ.desc =
| ConstantArrayType (_, {arti_element_type; arti_stride}, n) -> | ConstantArrayType (_, {arti_element_type; arti_stride}, n) ->
build_array_type translate_decl tenv arti_element_type (Some n) arti_stride build_array_type translate_decl tenv arti_element_type (Some n) arti_stride
| FunctionProtoType _ | FunctionNoProtoType _ -> | FunctionProtoType _ | FunctionNoProtoType _ ->
Typ.Tfun false Typ.Tfun {no_return= false}
| ParenType (_, qual_type) -> | ParenType (_, qual_type) ->
(qual_type_to_sil_type translate_decl tenv qual_type).Typ.desc (qual_type_to_sil_type translate_decl tenv qual_type).Typ.desc
| DecayedType (_, qual_type) -> | DecayedType (_, qual_type) ->

@ -17,7 +17,7 @@ let tests =
let assert_empty = invariant "{ }" in let assert_empty = invariant "{ }" in
let int_typ = Typ.mk (Tint IInt) in let int_typ = Typ.mk (Tint IInt) in
let int_ptr_typ = Typ.mk (Tptr (int_typ, Pk_pointer)) in let int_ptr_typ = Typ.mk (Tptr (int_typ, Pk_pointer)) in
let fun_ptr_typ = Typ.mk (Tptr (Typ.mk (Tfun false), Pk_pointer)) in let fun_ptr_typ = Typ.mk (Tptr (Typ.mk (Tfun {no_return= false}), Pk_pointer)) in
let closure_exp captureds = let closure_exp captureds =
let mk_captured_var str = (Exp.Var (ident_of_str str), pvar_of_str str, int_ptr_typ) in let mk_captured_var str = (Exp.Var (ident_of_str str), pvar_of_str str, int_ptr_typ) in
let captured_vars = List.map ~f:mk_captured_var captureds in let captured_vars = List.map ~f:mk_captured_var captureds in

@ -16,7 +16,7 @@ let tests =
let open OUnit2 in let open OUnit2 in
let open AnalyzerTester.StructuredSil in let open AnalyzerTester.StructuredSil in
let assert_empty = invariant "{ }" in let assert_empty = invariant "{ }" in
let fun_ptr_typ = Typ.mk (Tptr (Typ.mk (Tfun false), Pk_pointer)) in let fun_ptr_typ = Typ.mk (Tptr (Typ.mk (Tfun {no_return= false}), Pk_pointer)) in
let closure_exp captured_pvars = let closure_exp captured_pvars =
let mk_captured_var str = (Exp.Var (ident_of_str str), pvar_of_str str, dummy_typ) in let mk_captured_var str = (Exp.Var (ident_of_str str), pvar_of_str str, dummy_typ) in
let captured_vars = List.map ~f:mk_captured_var captured_pvars in let captured_vars = List.map ~f:mk_captured_var captured_pvars in

Loading…
Cancel
Save