Added a function to test if procdesc is a destructor.

Reviewed By: dulmarod

Differential Revision: D5611084

fbshipit-source-id: f606742
master
Daiva Naudziuniene 8 years ago committed by Facebook Github Bot
parent 9f19f12a1b
commit 02c2e2b5bf

@ -501,6 +501,7 @@ module Procname = struct
type objc_cpp_method_kind =
| CPPMethod of string option (** with mangling *)
| CPPConstructor of (string option * bool) (** with mangling + is it constexpr? *)
| CPPDestructor of string option (** with mangling *)
| ObjCClassMethod
| ObjCInstanceMethod
| ObjCInternalMethod
@ -829,9 +830,14 @@ module Procname = struct
let is_objc_dealloc method_name = String.equal method_name "dealloc"
(** [is_dealloc pname] returns true if [pname] is the dealloc method in Objective-C
TODO: add case for C++ *)
let is_destructor = function ObjC_Cpp name -> is_objc_dealloc name.method_name | _ -> false
(** [is_dealloc pname] returns true if [pname] is the dealloc method in Objective-C *)
let is_destructor = function
| ObjC_Cpp {kind= CPPDestructor _}
-> true
| ObjC_Cpp name
-> is_objc_dealloc name.method_name
| _
-> false
let java_is_close = function Java js -> String.equal js.method_name "close" | _ -> false
@ -869,7 +875,7 @@ module Procname = struct
let c_method_kind_verbose_str kind =
match kind with
| CPPMethod m
| CPPMethod m | CPPDestructor m
-> "(" ^ (match m with None -> "" | Some s -> s) ^ ")"
| CPPConstructor (m, is_constexpr)
-> "{" ^ (match m with None -> "" | Some s -> s) ^ (if is_constexpr then "|constexpr" else "")

@ -283,6 +283,7 @@ module Procname : sig
type objc_cpp_method_kind =
| CPPMethod of string option (** with mangling *)
| CPPConstructor of (string option * bool) (** with mangling + is it constexpr? *)
| CPPDestructor of string option (** with mangling *)
| ObjCClassMethod
| ObjCInstanceMethod
| ObjCInternalMethod

@ -102,6 +102,8 @@ let mk_cpp_method ?tenv class_name method_name ?meth_decl mangled =
match meth_decl with
| Some Clang_ast_t.CXXConstructorDecl (_, _, _, _, {xmdi_is_constexpr})
-> Typ.Procname.CPPConstructor (mangled, xmdi_is_constexpr)
| Some Clang_ast_t.CXXDestructorDecl _
-> Typ.Procname.CPPDestructor mangled
| _
-> Typ.Procname.CPPMethod mangled
in

Loading…
Cancel
Save