From a274cdf785ddf765ce0efa0c60bdec12fdd38145 Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Mon, 18 Jun 2018 05:29:21 -0700 Subject: [PATCH] [IR] Add the flag is_variadic to the procedure attributes Reviewed By: mbouaziz Differential Revision: D8442801 fbshipit-source-id: 85566ff --- facebook-clang-plugins | 2 +- infer/src/IR/ProcAttributes.ml | 4 ++++ infer/src/IR/ProcAttributes.mli | 1 + infer/src/clang/CMethodProperties.ml | 17 +++++++++++++++++ infer/src/clang/CMethodProperties.mli | 2 ++ infer/src/clang/CType_decl.ml | 2 ++ infer/src/clang/cMethodSignature.ml | 5 ++++- infer/src/clang/cMethodSignature.mli | 6 ++++-- infer/src/clang/cMethod_trans.ml | 1 + 9 files changed, 36 insertions(+), 4 deletions(-) diff --git a/facebook-clang-plugins b/facebook-clang-plugins index f31f7c9c2..a20740984 160000 --- a/facebook-clang-plugins +++ b/facebook-clang-plugins @@ -1 +1 @@ -Subproject commit f31f7c9c28d8fb9b59c0dacc74a24e4bfe90a904 +Subproject commit a207409847b6d09e610776b113cd922621e96ed7 diff --git a/infer/src/IR/ProcAttributes.ml b/infer/src/IR/ProcAttributes.ml index 771855885..4d5094036 100644 --- a/infer/src/IR/ProcAttributes.ml +++ b/infer/src/IR/ProcAttributes.ml @@ -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) diff --git a/infer/src/IR/ProcAttributes.mli b/infer/src/IR/ProcAttributes.mli index 19eaff457..8d87fa7f7 100644 --- a/infer/src/IR/ProcAttributes.mli +++ b/infer/src/IR/ProcAttributes.mli @@ -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 *) diff --git a/infer/src/clang/CMethodProperties.ml b/infer/src/clang/CMethodProperties.ml index 68d5bbaaf..19c19c8f7 100644 --- a/infer/src/clang/CMethodProperties.ml +++ b/infer/src/clang/CMethodProperties.ml @@ -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 diff --git a/infer/src/clang/CMethodProperties.mli b/infer/src/clang/CMethodProperties.mli index 15d1136bb..710aa6281 100644 --- a/infer/src/clang/CMethodProperties.mli +++ b/infer/src/clang/CMethodProperties.mli @@ -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 diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index eae536bd3..48a027e9d 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -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 } diff --git a/infer/src/clang/cMethodSignature.ml b/infer/src/clang/cMethodSignature.ml index b03b1b26a..769cf053e 100644 --- a/infer/src/clang/cMethodSignature.ml +++ b/infer/src/clang/cMethodSignature.ml @@ -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 } diff --git a/infer/src/clang/cMethodSignature.mli b/infer/src/clang/cMethodSignature.mli index ae9c1f6ca..6b2d11de2 100644 --- a/infer/src/clang/cMethodSignature.mli +++ b/infer/src/clang/cMethodSignature.mli @@ -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 diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index 4ee1ee71b..5ca35dc65 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -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