[IR] Add the flag is_variadic to the procedure attributes

Reviewed By: mbouaziz

Differential Revision: D8442801

fbshipit-source-id: 85566ff
master
Dulma Churchill 7 years ago committed by Facebook Github Bot
parent f80af7be93
commit a274cdf785

@ -1 +1 @@
Subproject commit f31f7c9c28d8fb9b59c0dacc74a24e4bfe90a904
Subproject commit a207409847b6d09e610776b113cd922621e96ed7

@ -101,6 +101,7 @@ type t =
; is_model: bool (** the procedure is a model *)
; is_specialized: bool (** the procedure is a clone specialized for dynamic dispatch handling *)
; is_synthetic_method: bool (** the procedure is a synthetic method *)
; is_variadic: bool (** the procedure is variadic, only supported for Clang procedures *)
; clang_method_kind: clang_method_kind (** the kind of method the procedure is *)
; loc: Location.t (** location of this procedure in the source code *)
; translation_unit: SourceFile.t (** translation unit to which the procedure belongs *)
@ -130,6 +131,7 @@ let default proc_name =
; is_model= false
; is_specialized= false
; is_synthetic_method= false
; is_variadic= false
; clang_method_kind= C_FUNCTION
; loc= Location.dummy
; translation_unit= SourceFile.invalid __FILE__
@ -163,6 +165,7 @@ let pp f
; is_model
; is_specialized
; is_synthetic_method
; is_variadic
; clang_method_kind
; loc
; translation_unit
@ -214,6 +217,7 @@ let pp f
pp_bool_default ~default:default.is_specialized "is_specialized" is_specialized f () ;
pp_bool_default ~default:default.is_synthetic_method "is_synthetic_method" is_synthetic_method f
() ;
pp_bool_default ~default:default.is_variadic "is_variadic" is_variadic f () ;
if not ([%compare.equal : clang_method_kind] default.clang_method_kind clang_method_kind) then
F.fprintf f "; clang_method_kind= %a@,"
(Pp.to_string ~f:string_of_clang_method_kind)

@ -58,6 +58,7 @@ type t =
; is_model: bool (** the procedure is a model *)
; is_specialized: bool (** the procedure is a clone specialized for dynamic dispatch handling *)
; is_synthetic_method: bool (** the procedure is a synthetic method *)
; is_variadic: bool (** the procedure is variadic, only supported for Clang procedures *)
; clang_method_kind: clang_method_kind (** the kind of method the procedure is *)
; loc: Location.t (** location of this procedure in the source code *)
; translation_unit: SourceFile.t (** translation unit to which the procedure belongs *)

@ -130,3 +130,20 @@ let get_pointer_to_property method_decl =
let is_objc_method method_decl =
match method_decl with Clang_ast_t.ObjCMethodDecl _ -> true | _ -> false
let is_variadic method_decl =
let open Clang_ast_t in
match method_decl with
| FunctionDecl (_, _, _, function_decl_info)
| CXXMethodDecl (_, _, _, function_decl_info, _)
| CXXConstructorDecl (_, _, _, function_decl_info, _)
| CXXConversionDecl (_, _, _, function_decl_info, _)
| CXXDestructorDecl (_, _, _, function_decl_info, _) ->
function_decl_info.fdi_is_variadic
| ObjCMethodDecl (_, _, method_decl_info) ->
method_decl_info.Clang_ast_t.omdi_is_variadic
| BlockDecl (_, block_decl_info) ->
block_decl_info.bdi_is_variadic
| _ ->
raise CFrontend_config.Invalid_declaration

@ -27,3 +27,5 @@ val get_init_list_instrs :
val get_pointer_to_property : Clang_ast_t.decl -> Clang_ast_t.pointer option
val is_objc_method : Clang_ast_t.decl -> bool
val is_variadic : Clang_ast_t.decl -> bool

@ -140,6 +140,7 @@ module BuildMethodSignature = struct
let attributes = decl_info.Clang_ast_t.di_attributes in
let is_cpp_virtual = CMethodProperties.is_cpp_virtual method_decl in
let is_cpp_nothrow = CMethodProperties.is_cpp_nothrow method_decl in
let is_variadic = CMethodProperties.is_variadic method_decl in
let access = decl_info.Clang_ast_t.di_access in
let pointer_to_property_opt = CMethodProperties.get_pointer_to_property method_decl in
{ CMethodSignature.name= procname
@ -152,6 +153,7 @@ module BuildMethodSignature = struct
; method_kind
; is_cpp_virtual
; is_cpp_nothrow
; is_variadic
; pointer_to_parent
; pointer_to_property_opt
; return_param_typ }

@ -31,6 +31,7 @@ type t =
; method_kind: ProcAttributes.clang_method_kind
; is_cpp_virtual: bool
; is_cpp_nothrow: bool
; is_variadic: bool
; pointer_to_parent: Clang_ast_t.pointer option
; pointer_to_property_opt: Clang_ast_t.pointer option
; (* If set then method is a getter/setter *)
@ -49,9 +50,10 @@ let is_setter {pointer_to_property_opt; params} =
let mk name class_param params ret_type attributes loc method_kind ?is_cpp_virtual ?is_cpp_nothrow
pointer_to_parent pointer_to_property_opt return_param_typ access =
?is_variadic pointer_to_parent pointer_to_property_opt return_param_typ access =
let is_cpp_virtual = Option.value is_cpp_virtual ~default:false in
let is_cpp_nothrow = Option.value is_cpp_nothrow ~default:false in
let is_variadic = Option.value is_variadic ~default:false in
{ name
; access
; class_param
@ -62,6 +64,7 @@ let mk name class_param params ret_type attributes loc method_kind ?is_cpp_virtu
; method_kind
; is_cpp_virtual
; is_cpp_nothrow
; is_variadic
; pointer_to_parent
; pointer_to_property_opt
; return_param_typ }

@ -24,6 +24,7 @@ type t =
; method_kind: ProcAttributes.clang_method_kind
; is_cpp_virtual: bool
; is_cpp_nothrow: bool
; is_variadic: bool
; pointer_to_parent: Clang_ast_t.pointer option
; pointer_to_property_opt: Clang_ast_t.pointer option
; (* If set then method is a getter/setter *)
@ -36,8 +37,9 @@ val is_setter : t -> bool
val mk :
Typ.Procname.t -> param_type option -> param_type list -> Typ.t * Annot.Item.t
-> Clang_ast_t.attribute list -> Clang_ast_t.source_range -> ProcAttributes.clang_method_kind
-> ?is_cpp_virtual:bool -> ?is_cpp_nothrow:bool -> Clang_ast_t.pointer option
-> Clang_ast_t.pointer option -> Typ.t option -> Clang_ast_t.access_specifier -> t
-> ?is_cpp_virtual:bool -> ?is_cpp_nothrow:bool -> ?is_variadic:bool
-> Clang_ast_t.pointer option -> Clang_ast_t.pointer option -> Typ.t option
-> Clang_ast_t.access_specifier -> t
val pp : Format.formatter -> t -> unit

@ -278,6 +278,7 @@ let create_local_procdesc ?(set_objc_accessor_attr= false) trans_unit_ctx cfg te
; is_defined= defined
; is_cpp_noexcept_method= is_cpp_nothrow
; is_model= Config.models_mode
; is_variadic= ms.CMethodSignature.is_variadic
; loc= loc_start
; clang_method_kind
; objc_accessor= objc_property_accessor

Loading…
Cancel
Save