diff --git a/infer/src/IR/ProcAttributes.ml b/infer/src/IR/ProcAttributes.ml index 4abb6502d0..82a4be1190 100644 --- a/infer/src/IR/ProcAttributes.ml +++ b/infer/src/IR/ProcAttributes.ml @@ -107,6 +107,7 @@ type t = ; is_cpp_copy_assignment: bool (** true if the procedure is a copy assignment *) ; is_cpp_copy_ctor: bool (** true if the procedure is a copy constructor *) ; is_cpp_move_ctor: bool (** true if the procedure is a move constructor *) + ; is_static_ctor: bool (** true if the procedure has the constructor attribute *) ; is_cpp_deleted: bool (** true if the procedure is deleted *) ; is_cpp_implicit: bool (** returns false if the declaration exists in code and true if it was created implicitly by @@ -203,6 +204,7 @@ let default translation_unit proc_name = ; is_cpp_copy_assignment= false ; is_cpp_copy_ctor= false ; is_cpp_move_ctor= false + ; is_static_ctor= false ; is_cpp_deleted= false ; is_cpp_implicit= false ; is_defined= false @@ -282,6 +284,7 @@ let pp f ; is_cpp_copy_assignment ; is_cpp_copy_ctor ; is_cpp_move_ctor + ; is_static_ctor ; is_cpp_deleted ; is_cpp_implicit ; is_defined @@ -347,6 +350,7 @@ let pp f is_cpp_copy_assignment f () ; pp_bool_default ~default:default.is_cpp_copy_ctor "is_cpp_copy_ctor" is_cpp_copy_ctor f () ; pp_bool_default ~default:default.is_cpp_move_ctor "is_cpp_move_ctor" is_cpp_move_ctor f () ; + pp_bool_default ~default:default.is_static_ctor "is_static_ctor" is_static_ctor f () ; pp_bool_default ~default:default.is_cpp_deleted "is_deleted" is_cpp_deleted f () ; pp_bool_default ~default:default.is_cpp_implicit "is_cpp_implicit" is_cpp_implicit f () ; pp_bool_default ~default:default.is_defined "is_defined" is_defined f () ; diff --git a/infer/src/IR/ProcAttributes.mli b/infer/src/IR/ProcAttributes.mli index 0366633edb..5ce128a08d 100644 --- a/infer/src/IR/ProcAttributes.mli +++ b/infer/src/IR/ProcAttributes.mli @@ -69,6 +69,7 @@ type t = ; is_cpp_copy_assignment: bool (** true if the procedure is a copy assignment *) ; is_cpp_copy_ctor: bool (** true if the procedure is a copy constructor *) ; is_cpp_move_ctor: bool (** true if the procedure is a move constructor *) + ; is_static_ctor: bool (** true if the procedure has the constructor attribute *) ; is_cpp_deleted: bool (** true if the procedure is deleted *) ; is_cpp_implicit: bool (** returns false if the declaration exists in code and true if it was created implicitly by diff --git a/infer/src/clang/CMethodProperties.ml b/infer/src/clang/CMethodProperties.ml index 3d56d603e3..111216b3b0 100644 --- a/infer/src/clang/CMethodProperties.ml +++ b/infer/src/clang/CMethodProperties.ml @@ -174,6 +174,17 @@ let is_cpp_move_ctor method_decl = false +let is_static_ctor method_decl = + let open Clang_ast_t in + match method_decl with + | FunctionDecl (decl_info, _, _, _) -> + let attributes = decl_info.Clang_ast_t.di_attributes in + List.exists attributes ~f:(fun attr -> + match attr with `ConstructorAttr _ -> true | _ -> false ) + | _ -> + false + + let is_cpp_deleted method_decl = let open Clang_ast_t in match method_decl with diff --git a/infer/src/clang/CMethodProperties.mli b/infer/src/clang/CMethodProperties.mli index 23723a3f96..794df9b0a8 100644 --- a/infer/src/clang/CMethodProperties.mli +++ b/infer/src/clang/CMethodProperties.mli @@ -33,6 +33,8 @@ val is_cpp_copy_ctor : Clang_ast_t.decl -> bool val is_cpp_move_ctor : Clang_ast_t.decl -> bool +val is_static_ctor : Clang_ast_t.decl -> bool + val is_cpp_deleted : Clang_ast_t.decl -> bool val is_constexpr : Clang_ast_t.decl -> bool diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index fc97875254..fa8dea2832 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -192,6 +192,7 @@ module BuildMethodSignature = struct let is_cpp_copy_assignment = CMethodProperties.is_cpp_copy_assignment method_decl in let is_cpp_copy_ctor = CMethodProperties.is_cpp_copy_ctor method_decl in let is_cpp_move_ctor = CMethodProperties.is_cpp_move_ctor method_decl in + let is_static_ctor = CMethodProperties.is_static_ctor method_decl in let is_cpp_deleted = CMethodProperties.is_cpp_deleted method_decl in let is_cpp_implicit = CAst_utils.is_cpp_implicit_decl method_decl in let is_no_return = CMethodProperties.is_no_return method_decl in @@ -206,6 +207,7 @@ module BuildMethodSignature = struct ; is_cpp_copy_assignment ; is_cpp_copy_ctor ; is_cpp_move_ctor + ; is_static_ctor ; is_cpp_deleted ; is_cpp_implicit ; ret_type= (ret_type, ret_typ_annot) diff --git a/infer/src/clang/cMethodSignature.ml b/infer/src/clang/cMethodSignature.ml index 4fb747e2a9..ee49a8cb6a 100644 --- a/infer/src/clang/cMethodSignature.ml +++ b/infer/src/clang/cMethodSignature.ml @@ -42,6 +42,7 @@ type t = ; is_cpp_copy_assignment: bool ; is_cpp_copy_ctor: bool ; is_cpp_move_ctor: bool + ; is_static_ctor: bool ; is_cpp_deleted: bool ; is_cpp_implicit: bool ; block_as_arg_attributes: ProcAttributes.block_as_arg_attributes option @@ -68,9 +69,9 @@ let is_setter {pointer_to_property_opt; params} = let mk name class_param params ret_type ?(has_added_return_param = false) ?(is_ret_type_pod = true) ~is_ret_constexpr attributes loc method_kind ?(is_cpp_const_member_fun = false) ?(is_cpp_virtual = false) ?(is_cpp_copy_assignment = false) ?(is_cpp_copy_ctor = false) - ?(is_cpp_move_ctor = false) ?(is_cpp_deleted = false) ?(is_cpp_implicit = false) - ?(block_as_arg_attributes = None) ?(is_no_return = false) ?(is_variadic = false) - pointer_to_parent pointer_to_property_opt return_param_typ access = + ?(is_cpp_move_ctor = false) ?(is_static_ctor = false) ?(is_cpp_deleted = false) + ?(is_cpp_implicit = false) ?(block_as_arg_attributes = None) ?(is_no_return = false) + ?(is_variadic = false) pointer_to_parent pointer_to_property_opt return_param_typ access = { name ; access ; class_param @@ -87,6 +88,7 @@ let mk name class_param params ret_type ?(has_added_return_param = false) ?(is_r ; is_cpp_copy_assignment ; is_cpp_copy_ctor ; is_cpp_move_ctor + ; is_static_ctor ; is_cpp_deleted ; is_cpp_implicit ; block_as_arg_attributes diff --git a/infer/src/clang/cMethodSignature.mli b/infer/src/clang/cMethodSignature.mli index cadfd2fc15..f559bf9ea9 100644 --- a/infer/src/clang/cMethodSignature.mli +++ b/infer/src/clang/cMethodSignature.mli @@ -35,6 +35,7 @@ type t = ; is_cpp_copy_assignment: bool ; is_cpp_copy_ctor: bool ; is_cpp_move_ctor: bool + ; is_static_ctor: bool ; is_cpp_deleted: bool ; is_cpp_implicit: bool ; block_as_arg_attributes: ProcAttributes.block_as_arg_attributes option @@ -65,6 +66,7 @@ val mk : -> ?is_cpp_copy_assignment:bool -> ?is_cpp_copy_ctor:bool -> ?is_cpp_move_ctor:bool + -> ?is_static_ctor:bool -> ?is_cpp_deleted:bool -> ?is_cpp_implicit:bool -> ?block_as_arg_attributes:ProcAttributes.block_as_arg_attributes option diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index cdd71581e2..bd0ca28559 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -245,6 +245,7 @@ let create_attributes_helper ?loc_instantiated ?(set_objc_accessor_attr = false) ; is_cpp_const_member_fun= ms.CMethodSignature.is_cpp_const_member_fun ; is_cpp_copy_ctor= ms.CMethodSignature.is_cpp_copy_ctor ; is_cpp_move_ctor= ms.CMethodSignature.is_cpp_move_ctor + ; is_static_ctor= ms.CMethodSignature.is_static_ctor ; is_cpp_copy_assignment= ms.CMethodSignature.is_cpp_copy_assignment ; is_cpp_deleted= ms.CMethodSignature.is_cpp_deleted ; is_cpp_implicit= ms.CMethodSignature.is_cpp_implicit