[IR] Refactor Ident.fieldname _*into Fieldname module

Reviewed By: jberdine

Differential Revision: D4745840

fbshipit-source-id: 4140221
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent b7f3116ca7
commit 7c64d217f2

@ -21,7 +21,7 @@ type t =
| Cstr string /** string constants */
| Cfloat float /** float constants */
| Cclass Ident.name /** class constant */
| Cptr_to_fld Ident.fieldname Typ.t /** pointer to field constant, and type of the surrounding Csu.t type */
| Cptr_to_fld Fieldname.t Typ.t /** pointer to field constant, and type of the surrounding Csu.t type */
[@@deriving compare];
let equal = [%compare.equal : t];
@ -49,7 +49,7 @@ let pp pe f =>
| Cstr s => F.fprintf f "\"%s\"" (String.escaped s)
| Cfloat v => F.fprintf f "%f" v
| Cclass c => F.fprintf f "%a" Ident.pp_name c
| Cptr_to_fld fn _ => F.fprintf f "__fld_%a" Ident.pp_fieldname fn;
| Cptr_to_fld fn _ => F.fprintf f "__fld_%a" Fieldname.pp fn;
let to_string c => F.asprintf "%a" (pp Pp.text) c;

@ -23,7 +23,7 @@ type t =
| Cstr string /** string constants */
| Cfloat float /** float constants */
| Cclass Ident.name /** class constant */
| Cptr_to_fld Ident.fieldname Typ.t /** pointer to field constant, and type of the surrounding Csu.t type */
| Cptr_to_fld Fieldname.t Typ.t /** pointer to field constant, and type of the surrounding Csu.t type */
[@@deriving compare];
let equal: t => t => bool;

@ -24,8 +24,8 @@ type t =
| Dsizeof Typ.t (option t) Subtype.t
| Dderef t
| Dfcall t (list t) Location.t CallFlags.t
| Darrow t Ident.fieldname
| Ddot t Ident.fieldname
| Darrow t Fieldname.t
| Ddot t Fieldname.t
| Dpvar Pvar.t
| Dpvaraddr Pvar.t
| Dunop Unop.t t
@ -90,25 +90,25 @@ let rec to_string =
}
| Darrow (Dpvar pv) f when Pvar.is_this pv =>
/* this->fieldname */
Ident.fieldname_to_simplified_string f
Fieldname.to_simplified_string f
| Darrow de f =>
if (Ident.fieldname_is_hidden f) {
if (Fieldname.is_hidden f) {
to_string de
} else if (java ()) {
to_string de ^ "." ^ Ident.fieldname_to_flat_string f
to_string de ^ "." ^ Fieldname.to_flat_string f
} else {
to_string de ^ "->" ^ Ident.fieldname_to_string f
to_string de ^ "->" ^ Fieldname.to_string f
}
| Ddot (Dpvar _) fe when eradicate_java () =>
/* static field access */
Ident.fieldname_to_simplified_string fe
Fieldname.to_simplified_string fe
| Ddot de f =>
if (Ident.fieldname_is_hidden f) {
if (Fieldname.is_hidden f) {
"&" ^ to_string de
} else if (java ()) {
to_string de ^ "." ^ Ident.fieldname_to_flat_string f
to_string de ^ "." ^ Fieldname.to_flat_string f
} else {
to_string de ^ "." ^ Ident.fieldname_to_string f
to_string de ^ "." ^ Fieldname.to_string f
}
| Dpvar pv => Mangled.to_string (Pvar.get_name pv)
| Dpvaraddr pv => {

@ -24,8 +24,8 @@ type t =
| Dsizeof Typ.t (option t) Subtype.t
| Dderef t
| Dfcall t (list t) Location.t CallFlags.t
| Darrow t Ident.fieldname
| Ddot t Ident.fieldname
| Darrow t Fieldname.t
| Ddot t Fieldname.t
| Dpvar Pvar.t
| Dpvaraddr Pvar.t
| Dunop Unop.t t

@ -76,7 +76,7 @@ exception Java_runtime_exception of Typ.Name.t * string * Localise.error_desc
exception Leak of
bool * Sil.hpred * (visibility * Localise.error_desc)
* bool * PredSymb.resource * L.ml_loc
exception Missing_fld of Ident.fieldname * L.ml_loc
exception Missing_fld of Fieldname.t * L.ml_loc
exception Premature_nil_termination of Localise.error_desc * L.ml_loc
exception Null_dereference of Localise.error_desc * L.ml_loc
exception Null_test_after_dereference of Localise.error_desc * L.ml_loc
@ -230,7 +230,7 @@ let recognize_exception exn =
(Localise.from_string "Match failure",
Localise.no_desc, Some ml_loc, Exn_developer, High, None, Nocat)
| Missing_fld (fld, ml_loc) ->
let desc = Localise.verbatim_desc (Ident.fieldname_to_string fld) in
let desc = Localise.verbatim_desc (Fieldname.to_string fld) in
(Localise.from_string "Missing_fld" ~hum:"Missing Field",
desc, Some ml_loc, Exn_developer, Medium, None, Nocat)
| Premature_nil_termination (desc, ml_loc) ->

@ -71,7 +71,7 @@ exception Java_runtime_exception of Typ.Name.t * string * Localise.error_desc
exception Leak of
bool * Sil.hpred * (visibility * Localise.error_desc)
* bool * PredSymb.resource * Logging.ml_loc
exception Missing_fld of Ident.fieldname * Logging.ml_loc
exception Missing_fld of Fieldname.t * Logging.ml_loc
exception Premature_nil_termination of Localise.error_desc * Logging.ml_loc
exception Null_dereference of Localise.error_desc * Logging.ml_loc
exception Null_test_after_dereference of Localise.error_desc * Logging.ml_loc

@ -44,7 +44,7 @@ and t =
/** The address of a program variable */
| Lvar Pvar.t
/** A field offset, the type is the surrounding struct type */
| Lfield t Ident.fieldname Typ.t
| Lfield t Fieldname.t Typ.t
/** An array index offset: [exp1\[exp2\]] */
| Lindex t t
/** A sizeof expression. [Sizeof (Tarray elt (Some static_length)) (Some dynamic_length)]
@ -233,7 +233,7 @@ let rec pp_ pe pp_t f e => {
let id_exps = List.map f::(fun (id_exp, _, _) => id_exp) captured_vars;
F.fprintf f "(%a)" (Pp.comma_seq pp_exp) [Const (Cfun name), ...id_exps]
| Lvar pv => Pvar.pp pe f pv
| Lfield e fld _ => F.fprintf f "%a.%a" pp_exp e Ident.pp_fieldname fld
| Lfield e fld _ => F.fprintf f "%a.%a" pp_exp e Fieldname.pp fld
| Lindex e1 e2 => F.fprintf f "%a[%a]" pp_exp e1 pp_exp e2
| Sizeof t l s =>
let pp_len f l => Option.iter f::(F.fprintf f "[%a]" pp_exp) l;

@ -37,7 +37,7 @@ and t =
/** The address of a program variable */
| Lvar Pvar.t
/** A field offset, the type is the surrounding struct type */
| Lfield t Ident.fieldname Typ.t
| Lfield t Fieldname.t Typ.t
/** An array index offset: [exp1\[exp2\]] */
| Lindex t t
/** A sizeof expression. [Sizeof (Tarray elt (Some static_length)) (Some dynamic_length)]

@ -0,0 +1,106 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
open! IStd;
let module Hashtbl = Caml.Hashtbl;
type t = {fpos: int, fname: Mangled.t} [@@deriving compare];
let equal = [%compare.equal : t];
let module Set = Caml.Set.Make {
type nonrec t = t;
let compare = compare;
};
let module Map = Caml.Map.Make {
type nonrec t = t;
let compare = compare;
};
/** Create a field name with the given position (field number in the CSU) */
let create (n: Mangled.t) (position: int) => {fpos: position, fname: n};
/** Convert a fieldname to a string. */
let to_string fn => Mangled.to_string fn.fname;
/** Convert a fieldname to a string, including the mangled part. */
let to_complete_string fn => Mangled.to_string_full fn.fname;
/** Convert a fieldname to a simplified string with at most one-level path. */
let to_simplified_string fn => {
let s = Mangled.to_string fn.fname;
switch (String.rsplit2 s on::'.') {
| Some (s1, s2) =>
switch (String.rsplit2 s1 on::'.') {
| Some (_, s4) => s4 ^ "." ^ s2
| _ => s
}
| _ => s
}
};
/** Convert a fieldname to a flat string without path. */
let to_flat_string fn => {
let s = Mangled.to_string fn.fname;
switch (String.rsplit2 s on::'.') {
| Some (_, s2) => s2
| _ => s
}
};
let pp f fn =>
/* only use for debug F.fprintf f "%a#%d" pp_name fn.fname fn.fpos */
Mangled.pp f fn.fname;
let pp_latex style f fn => Latex.pp_string style f (Mangled.to_string fn.fname);
/** Returns the class part of the fieldname */
let java_get_class fn => {
let fn = to_string fn;
let ri = String.rindex_exn fn '.';
String.slice fn 0 ri
};
/** Returns the last component of the fieldname */
let java_get_field fn => {
let fn = to_string fn;
let ri = 1 + String.rindex_exn fn '.';
String.slice fn ri 0
};
/** Check if the field is the synthetic this$n of a nested class, used to access the n-th outher instance. */
let java_is_outer_instance fn => {
let fn = to_string fn;
let fn_len = String.length fn;
fn_len != 0 && {
let this = ".this$";
let last_char = fn.[fn_len - 1];
(last_char >= '0' && last_char <= '9') &&
String.is_suffix fn suffix::(this ^ String.of_char last_char)
}
};
let fieldname_offset fn => fn.fpos;
/** hidded fieldname constant */
let hidden = create (Mangled.from_string ".hidden") 0;
/** hidded fieldname constant */
let is_hidden fn => equal fn hidden;

@ -0,0 +1,73 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
open! IStd;
/** Names for fields of class/struct/union */
type t [@@deriving compare];
/** Equality for field names. */
let equal: t => t => bool;
/** Set for fieldnames */
let module Set: Caml.Set.S with type elt = t;
/** Map for fieldnames */
let module Map: Caml.Map.S with type key = t;
/** Create a field name at the given position */
let create: Mangled.t => int => t;
/** Convert a field name to a string. */
let to_string: t => string;
/** Convert a fieldname to a string, including the mangled part. */
let to_complete_string: t => string;
/** Convert a fieldname to a simplified string with at most one-level path. */
let to_simplified_string: t => string;
/** Convert a fieldname to a flat string without path. */
let to_flat_string: t => string;
/** Pretty print a field name. */
let pp: Format.formatter => t => unit;
/** Pretty print a field name in latex. */
let pp_latex: Latex.style => Format.formatter => t => unit;
/** The class part of the fieldname */
let java_get_class: t => string;
/** The last component of the fieldname */
let java_get_field: t => string;
/** Check if the field is the synthetic this$n of a nested class, used to access the n-th outher instance. */
let java_is_outer_instance: t => bool;
/** hidded fieldname constant */
let hidden: t;
/** hidded fieldname constant */
let is_hidden: t => bool;

@ -48,10 +48,6 @@ let name_primed = Name.Primed;
let equal_name = [%compare.equal : name];
type fieldname = {fpos: int, fname: Mangled.t} [@@deriving compare];
let equal_fieldname = [%compare.equal : fieldname];
type kind =
| KNone
/** special kind of "null ident" (basically, a more compact way of implementing an ident option).
@ -96,14 +92,6 @@ let module IdentHash = Hashtbl.Make {
let hash (id: t) => Hashtbl.hash id;
};
let module FieldSet = Caml.Set.Make {
type t = fieldname [@@deriving compare];
};
let module FieldMap = Caml.Map.Make {
type t = fieldname [@@deriving compare];
};
let idlist_to_idset ids =>
List.fold f::(fun set id => IdentSet.add id set) init::IdentSet.empty ids;
@ -120,85 +108,9 @@ let module NameHash = Hashtbl.Make {
let string_to_name = Name.from_string;
/** Create a field name with the given position (field number in the CSU) */
let create_fieldname (n: Mangled.t) (position: int) => {fpos: position, fname: n};
/** Convert a name to a string. */
let name_to_string = Name.to_string;
/** Convert a fieldname to a string. */
let fieldname_to_string fn => Mangled.to_string fn.fname;
/** Convert a fieldname to a string, including the mangled part. */
let fieldname_to_complete_string fn => Mangled.to_string_full fn.fname;
/** Convert a fieldname to a simplified string with at most one-level path. */
let fieldname_to_simplified_string fn => {
let s = Mangled.to_string fn.fname;
switch (String.rsplit2 s on::'.') {
| Some (s1, s2) =>
switch (String.rsplit2 s1 on::'.') {
| Some (_, s4) => s4 ^ "." ^ s2
| _ => s
}
| _ => s
}
};
/** Convert a fieldname to a flat string without path. */
let fieldname_to_flat_string fn => {
let s = Mangled.to_string fn.fname;
switch (String.rsplit2 s on::'.') {
| Some (_, s2) => s2
| _ => s
}
};
/** Returns the class part of the fieldname */
let java_fieldname_get_class fn => {
let fn = fieldname_to_string fn;
let ri = String.rindex_exn fn '.';
String.slice fn 0 ri
};
/** Returns the last component of the fieldname */
let java_fieldname_get_field fn => {
let fn = fieldname_to_string fn;
let ri = 1 + String.rindex_exn fn '.';
String.slice fn ri 0
};
/** Check if the field is the synthetic this$n of a nested class, used to access the n-th outher instance. */
let java_fieldname_is_outer_instance fn => {
let fn = fieldname_to_string fn;
let fn_len = String.length fn;
fn_len != 0 && {
let this = ".this$";
let last_char = fn.[fn_len - 1];
(last_char >= '0' && last_char <= '9') &&
String.is_suffix fn suffix::(this ^ String.of_char last_char)
}
};
let fieldname_offset fn => fn.fpos;
/** hidded fieldname constant */
let fieldname_hidden = create_fieldname (Mangled.from_string ".hidden") 0;
/** hidded fieldname constant */
let fieldname_is_hidden fn => equal_fieldname fn fieldname_hidden;
/** {2 Functions and Hash Tables for Managing Stamps} */
/** Set the stamp of the identifier */
@ -356,16 +268,10 @@ let to_string id =>
/** Pretty print a name. */
let pp_name f name => F.fprintf f "%s" (name_to_string name);
let pp_fieldname f fn =>
/* only use for debug F.fprintf f "%a#%d" pp_name fn.fname fn.fpos */
Mangled.pp f fn.fname;
/** Pretty print a name in latex. */
let pp_name_latex style f (name: name) => Latex.pp_string style f (name_to_string name);
let pp_fieldname_latex style f fn => Latex.pp_string style f (Mangled.to_string fn.fname);
/** Pretty print an identifier. */
let pp pe f id =>

@ -28,14 +28,6 @@ type name [@@deriving compare];
let equal_name: name => name => bool;
/** Names for fields of class/struct/union */
type fieldname [@@deriving compare];
/** Equality for field names. */
let equal_fieldname: fieldname => fieldname => bool;
/** Kind of identifiers. */
type kind [@@deriving compare];
@ -55,14 +47,6 @@ let module IdentHash: Caml.Hashtbl.S with type key = t;
/** Map with ident as key. */
let module IdentMap: Caml.Map.S with type key = t;
/** Set for fieldnames */
let module FieldSet: Caml.Set.S with type elt = fieldname;
/** Map for fieldnames */
let module FieldMap: Caml.Map.S with type key = fieldname;
let module NameGenerator: {
type t;
@ -107,54 +91,10 @@ let name_return: Mangled.t;
let string_to_name: string => name;
/** Create a field name at the given position */
let create_fieldname: Mangled.t => int => fieldname;
/** Convert a name to a string. */
let name_to_string: name => string;
/** Convert a field name to a string. */
let fieldname_to_string: fieldname => string;
/** Convert a fieldname to a string, including the mangled part. */
let fieldname_to_complete_string: fieldname => string;
/** Convert a fieldname to a simplified string with at most one-level path. */
let fieldname_to_simplified_string: fieldname => string;
/** Convert a fieldname to a flat string without path. */
let fieldname_to_flat_string: fieldname => string;
/** The class part of the fieldname */
let java_fieldname_get_class: fieldname => string;
/** The last component of the fieldname */
let java_fieldname_get_field: fieldname => string;
/** Check if the field is the synthetic this$n of a nested class, used to access the n-th outher instance. */
let java_fieldname_is_outer_instance: fieldname => bool;
/** get the offset of a fieldname */
let fieldname_offset: fieldname => int;
/** hidded fieldname constant */
let fieldname_hidden: fieldname;
/** hidded fieldname constant */
let fieldname_is_hidden: fieldname => bool;
/** Name of the identifier. */
let get_name: t => name;
@ -229,18 +169,10 @@ let set_stamp: t => int => t;
let pp_name: Format.formatter => name => unit;
/** Pretty print a field name. */
let pp_fieldname: Format.formatter => fieldname => unit;
/** Pretty print a name in latex. */
let pp_name_latex: Latex.style => Format.formatter => name => unit;
/** Pretty print a field name in latex. */
let pp_fieldname_latex: Latex.style => Format.formatter => fieldname => unit;
/** Pretty print an identifier. */
let pp: Pp.env => Format.formatter => t => unit;

@ -311,8 +311,8 @@ let rec format_typ = function
let format_field f =
if Config.curr_language_is Config.Java
then Ident.java_fieldname_get_field f
else Ident.fieldname_to_string f
then Fieldname.java_get_field f
else Fieldname.to_string f
let format_method pname =
match pname with
@ -471,11 +471,11 @@ let java_unchecked_exn_desc proc_name exn_name pre_str : error_desc =
}
let desc_context_leak pname context_typ fieldname leak_path : error_desc =
let fld_str = Ident.fieldname_to_string fieldname in
let fld_str = Fieldname.to_string fieldname in
let leak_root = "Static field " ^ fld_str ^ " |->\n" in
let leak_path_entry_to_str acc entry =
let entry_str = match entry with
| (Some fld, _) -> Ident.fieldname_to_string fld
| (Some fld, _) -> Fieldname.to_string fld
| (None, typ) -> Typ.to_string typ in
(* intentionally omit space; [typ_to_string] adds an extra space *)
acc ^ entry_str ^ " |->\n" in
@ -499,7 +499,7 @@ let desc_context_leak pname context_typ fieldname leak_path : error_desc =
let desc_unsafe_guarded_by_access pname accessed_fld guarded_by_str loc =
let line_info = at_line (Tags.create ()) loc in
let accessed_fld_str = Ident.fieldname_to_string accessed_fld in
let accessed_fld_str = Fieldname.to_string accessed_fld in
let annot_str = Printf.sprintf "@GuardedBy(\"%s\")" guarded_by_str in
let syncronized_str =
MF.monospaced_to_string (Printf.sprintf "synchronized(%s)" guarded_by_str) in
@ -600,7 +600,7 @@ let parameter_field_not_null_checked_desc (desc : error_desc) exp =
let field_not_nullable_desc exp =
let rec exp_to_string exp =
match exp with
| Exp.Lfield (exp', field, _) -> (exp_to_string exp')^" -> "^(Ident.fieldname_to_string field)
| Exp.Lfield (exp', field, _) -> (exp_to_string exp')^" -> "^(Fieldname.to_string field)
| Exp.Lvar pvar -> Mangled.to_string (Pvar.get_name pvar)
| _ -> "" in
let var_s = exp_to_string exp in
@ -835,7 +835,7 @@ let desc_retain_cycle cycle loc cycle_dotty =
match se with
| Sil.Eexp(Exp.Lvar pvar, _) when Pvar.equal pvar Sil.block_pvar ->
str_cycle:=!str_cycle^" ("^(string_of_int !ct)^") a block capturing " ^
MF.monospaced_to_string (Ident.fieldname_to_string f)^"; ";
MF.monospaced_to_string (Fieldname.to_string f)^"; ";
ct:=!ct +1;
| Sil.Eexp(Exp.Lvar pvar as e, _) ->
let e_str = Exp.to_string e in
@ -843,14 +843,14 @@ let desc_retain_cycle cycle loc cycle_dotty =
remove_old e_str
else e_str in
str_cycle:=!str_cycle^" ("^(string_of_int !ct)^") object "^e_str^" retaining " ^
MF.monospaced_to_string (e_str^"."^(Ident.fieldname_to_string f))^", ";
MF.monospaced_to_string (e_str^"."^(Fieldname.to_string f))^", ";
ct:=!ct +1
| Sil.Eexp (Exp.Sizeof (typ, _, _), _) ->
let step =
" (" ^ (string_of_int !ct) ^ ") an object of " ^
MF.monospaced_to_string (Typ.to_string typ) ^
" retaining another object via instance variable " ^
MF.monospaced_to_string (Ident.fieldname_to_string f) ^ ", " in
MF.monospaced_to_string (Fieldname.to_string f) ^ ", " in
str_cycle := !str_cycle ^ step;
ct:=!ct +1
| _ -> () in

@ -252,11 +252,11 @@ val desc_null_test_after_dereference : string -> int -> Location.t -> error_desc
val java_unchecked_exn_desc : Typ.Procname.t -> Typ.Name.t -> string -> error_desc
val desc_context_leak :
Typ.Procname.t -> Typ.t -> Ident.fieldname ->
(Ident.fieldname option * Typ.t) list -> error_desc
Typ.Procname.t -> Typ.t -> Fieldname.t ->
(Fieldname.t option * Typ.t) list -> error_desc
val desc_fragment_retains_view :
Typ.t -> Ident.fieldname -> Typ.t -> Typ.Procname.t -> error_desc
Typ.t -> Fieldname.t -> Typ.t -> Typ.Procname.t -> error_desc
(* Create human-readable error description for assertion failures *)
val desc_custom_error : Location.t -> error_desc
@ -271,7 +271,7 @@ val desc_precondition_not_met : pnm_kind option -> Typ.Procname.t -> Location.t
val desc_return_expression_required : string -> Location.t -> error_desc
val desc_retain_cycle :
((Sil.strexp * Typ.t) * Ident.fieldname * Sil.strexp) list ->
((Sil.strexp * Typ.t) * Fieldname.t * Sil.strexp) list ->
Location.t -> string option -> error_desc
val registered_observer_being_deallocated_str : string -> string
@ -292,7 +292,7 @@ val desc_unary_minus_applied_to_unsigned_expression :
string option -> string -> Location.t -> error_desc
val desc_unsafe_guarded_by_access :
Typ.Procname.t -> Ident.fieldname -> string -> Location.t -> error_desc
Typ.Procname.t -> Fieldname.t -> string -> Location.t -> error_desc
val desc_tainted_value_reaching_sensitive_function :
PredSymb.taint_kind -> string -> Typ.Procname.t -> Typ.Procname.t -> Location.t -> error_desc

@ -38,8 +38,8 @@ let proc_flags_find proc_flags key => Hashtbl.find proc_flags key;
/** Type for ObjC accessors */
type objc_accessor_type =
| Objc_getter Ident.fieldname
| Objc_setter Ident.fieldname
| Objc_getter Fieldname.t
| Objc_setter Fieldname.t
[@@deriving compare];
type t = {

@ -33,8 +33,8 @@ let proc_flags_add: proc_flags => string => string => unit;
let proc_flags_find: proc_flags => string => string;
type objc_accessor_type =
| Objc_getter Ident.fieldname
| Objc_setter Ident.fieldname
| Objc_getter Fieldname.t
| Objc_setter Fieldname.t
[@@deriving compare];
type t = {

@ -570,10 +570,8 @@ let pp_variable_list fmt etl =>
let pp_objc_accessor fmt accessor =>
switch accessor {
| Some (ProcAttributes.Objc_getter name) =>
Format.fprintf fmt "Getter of %a, " Ident.pp_fieldname name
| Some (ProcAttributes.Objc_setter name) =>
Format.fprintf fmt "Setter of %a, " Ident.pp_fieldname name
| Some (ProcAttributes.Objc_getter name) => Format.fprintf fmt "Getter of %a, " Fieldname.pp name
| Some (ProcAttributes.Objc_setter name) => Format.fprintf fmt "Setter of %a, " Fieldname.pp name
| None => ()
};

@ -80,7 +80,7 @@ let instr_is_auxiliary =
/** offset for an lvalue */
type offset =
| Off_fld Ident.fieldname Typ.t
| Off_fld Fieldname.t Typ.t
| Off_index Exp.t;
@ -136,7 +136,7 @@ let equal_inst = [%compare.equal : inst];
/** structured expressions represent a value of structured type, such as an array or a struct. */
type strexp0 'inst =
| Eexp Exp.t 'inst /** Base case: expression with instrumentation */
| Estruct (list (Ident.fieldname, strexp0 'inst)) 'inst /** C structure */
| Estruct (list (Fieldname.t, strexp0 'inst)) 'inst /** C structure */
/** Array of given length
There are two conditions imposed / used in the array case.
First, if some index and value pair appears inside an array
@ -407,7 +407,7 @@ let d_texp_full (te: Exp.t) => L.add_print_action (L.PTtexp_full, Obj.repr te);
/** Pretty print an offset */
let pp_offset pe f =>
fun
| Off_fld fld _ => F.fprintf f "%a" Ident.pp_fieldname fld
| Off_fld fld _ => F.fprintf f "%a" Fieldname.pp fld
| Off_index exp => F.fprintf f "%a" (pp_exp_printenv pe) exp;
@ -913,11 +913,11 @@ let rec pp_sexp_env pe0 envo f se => {
switch pe.Pp.kind {
| TEXT
| HTML =>
let pp_diff f (n, se) => F.fprintf f "%a:%a" Ident.pp_fieldname n (pp_sexp_env pe envo) se;
let pp_diff f (n, se) => F.fprintf f "%a:%a" Fieldname.pp n (pp_sexp_env pe envo) se;
F.fprintf f "{%a}%a" (pp_seq_diff pp_diff pe) fel (pp_inst_if_trace pe) inst
| LATEX =>
let pp_diff f (n, se) =>
F.fprintf f "%a:%a" (Ident.pp_fieldname_latex Latex.Boldface) n (pp_sexp_env pe envo) se;
F.fprintf f "%a:%a" (Fieldname.pp_latex Latex.Boldface) n (pp_sexp_env pe envo) se;
F.fprintf f "\\{%a\\}%a" (pp_seq_diff pp_diff pe) fel (pp_inst_if_trace pe) inst
}
| Earray len nel inst =>
@ -2043,7 +2043,7 @@ let rec exp_compare_structural e1 e2 exp_map => {
if (n != 0) {
n
} else {
let n = Ident.compare_fieldname f1 f2;
let n = Fieldname.compare f1 f2;
if (n != 0) {
n
} else {

@ -77,7 +77,7 @@ let instr_is_auxiliary: instr => bool;
/** Offset for an lvalue. */
type offset =
| Off_fld Ident.fieldname Typ.t
| Off_fld Fieldname.t Typ.t
| Off_index Exp.t;
@ -183,7 +183,7 @@ let inst_partial_meet: inst => inst => inst;
/** structured expressions represent a value of structured type, such as an array or a struct. */
type strexp0 'inst =
| Eexp Exp.t 'inst /** Base case: expression with instrumentation */
| Estruct (list (Ident.fieldname, strexp0 'inst)) 'inst /** C structure */
| Estruct (list (Fieldname.t, strexp0 'inst)) 'inst /** C structure */
/** Array of given length
There are two conditions imposed / used in the array case.
First, if some index and value pair appears inside an array

@ -915,7 +915,7 @@ let java_proc_return_typ pname_java =>
};
let module Struct = {
type field = (Ident.fieldname, T.t, Annot.Item.t) [@@deriving compare];
type field = (Fieldname.t, T.t, Annot.Item.t) [@@deriving compare];
type fields = list field;
/** Type for a structured value. */
@ -939,7 +939,7 @@ let module Struct = {
(
Pp.seq (
fun f (fld, t, a) =>
F.fprintf f "\n\t\t%a %a %a" (pp_full pe) t Ident.pp_fieldname fld Annot.Item.pp a
F.fprintf f "\n\t\t%a %a %a" (pp_full pe) t Fieldname.pp fld Annot.Item.pp a
)
)
fields
@ -1018,7 +1018,7 @@ let module Struct = {
| Tstruct name =>
switch (lookup name) {
| Some {fields} =>
List.find f::(fun (f, _, _) => Ident.equal_fieldname f fn) fields |>
List.find f::(fun (f, _, _) => Fieldname.equal f fn) fields |>
Option.value_map f::snd3 default::default
| None => default
}
@ -1031,7 +1031,7 @@ let module Struct = {
switch (lookup name) {
| Some {fields, statics} =>
List.find_map
f::(fun (f, t, a) => Ident.equal_fieldname f fn ? Some (t, a) : None) (fields @ statics)
f::(fun (f, t, a) => Fieldname.equal f fn ? Some (t, a) : None) (fields @ statics)
| None => None
}
| _ => None
@ -1039,7 +1039,7 @@ let module Struct = {
let objc_ref_counter_annot = [({Annot.class_name: "ref_counter", parameters: []}, false)];
/** Field used for objective-c reference counting */
let objc_ref_counter_field = (Ident.fieldname_hidden, T.Tint IInt, objc_ref_counter_annot);
let objc_ref_counter_field = (Fieldname.hidden, T.Tint IInt, objc_ref_counter_annot);
let is_objc_ref_counter_field (fld, _, a) =>
Ident.fieldname_is_hidden fld && Annot.Item.equal a objc_ref_counter_annot;
Fieldname.is_hidden fld && Annot.Item.equal a objc_ref_counter_annot;
};

@ -432,7 +432,7 @@ let module Procname: {
let java_proc_return_typ: Procname.java => t;
let module Struct: {
type field = (Ident.fieldname, typ, Annot.Item.t) [@@deriving compare];
type field = (Fieldname.t, typ, Annot.Item.t) [@@deriving compare];
type fields = list field;
/** Type for a structured value. */
@ -466,13 +466,13 @@ let module Struct: {
/** If a struct type with field f, return the type of f.
If not, return the default type if given, otherwise raise an exception */
let fld_typ: lookup::lookup => default::typ => Ident.fieldname => typ => typ;
let fld_typ: lookup::lookup => default::typ => Fieldname.t => typ => typ;
/** Return the type of the field [fn] and its annotation, None if [typ] has no field named [fn] */
let get_field_type_and_annotation:
lookup::lookup => Ident.fieldname => typ => option (typ, Annot.Item.t);
lookup::lookup => Fieldname.t => typ => option (typ, Annot.Item.t);
/** Field used for objective-c reference counting */
let objc_ref_counter_field: (Ident.fieldname, typ, Annot.Item.t);
let is_objc_ref_counter_field: (Ident.fieldname, typ, Annot.Item.t) => bool;
let objc_ref_counter_field: (Fieldname.t, typ, Annot.Item.t);
let is_objc_ref_counter_field: (Fieldname.t, typ, Annot.Item.t) => bool;
};

@ -388,7 +388,7 @@ let execute___get_hidden_field { Builtin.tenv; pdesc; prop_; path; ret_id; args;
| Some e -> return_result tenv e p ret_id
| None -> p in
let foot_var = lazy (Exp.Var (Ident.create_fresh Ident.kfootprint)) in
let filter_fld_hidden (f, _ ) = Ident.fieldname_is_hidden f in
let filter_fld_hidden (f, _ ) = Fieldname.is_hidden f in
let has_fld_hidden fsel = List.exists ~f:filter_fld_hidden fsel in
let do_hpred in_foot hpred = match hpred with
| Sil.Hpointsto(e, Sil.Estruct (fsel, inst), texp)
@ -396,7 +396,7 @@ let execute___get_hidden_field { Builtin.tenv; pdesc; prop_; path; ret_id; args;
let foot_e = Lazy.force foot_var in
ret_val := Some foot_e;
let se = Sil.Eexp(foot_e, Sil.inst_none) in
let fsel' = (Ident.fieldname_hidden, se) :: fsel in
let fsel' = (Fieldname.hidden, se) :: fsel in
Sil.Hpointsto(e, Sil.Estruct (fsel', inst), texp)
| Sil.Hpointsto(e, Sil.Estruct (fsel, _), _)
when Exp.equal e n_lexp && not in_foot && has_fld_hidden fsel ->
@ -426,21 +426,21 @@ let execute___set_hidden_field { Builtin.tenv; pdesc; prop_; path; args; }
let n_lexp1, prop__ = check_arith_norm_exp tenv pname lexp1 prop_ in
let n_lexp2, prop = check_arith_norm_exp tenv pname lexp2 prop__ in
let foot_var = lazy (Exp.Var (Ident.create_fresh Ident.kfootprint)) in
let filter_fld_hidden (f, _ ) = Ident.fieldname_is_hidden f in
let filter_fld_hidden (f, _ ) = Fieldname.is_hidden f in
let has_fld_hidden fsel = List.exists ~f:filter_fld_hidden fsel in
let do_hpred in_foot hpred = match hpred with
| Sil.Hpointsto(e, Sil.Estruct (fsel, inst), texp)
when Exp.equal e n_lexp1 && not in_foot ->
let se = Sil.Eexp(n_lexp2, Sil.inst_none) in
let fsel' =
(Ident.fieldname_hidden, se) ::
(Fieldname.hidden, se) ::
(List.filter ~f:(fun x -> not (filter_fld_hidden x)) fsel) in
Sil.Hpointsto(e, Sil.Estruct (fsel', inst), texp)
| Sil.Hpointsto(e, Sil.Estruct (fsel, inst), texp)
when Exp.equal e n_lexp1 && in_foot && not (has_fld_hidden fsel) ->
let foot_e = Lazy.force foot_var in
let se = Sil.Eexp(foot_e, Sil.inst_none) in
let fsel' = (Ident.fieldname_hidden, se) :: fsel in
let fsel' = (Fieldname.hidden, se) :: fsel in
Sil.Hpointsto(e, Sil.Estruct (fsel', inst), texp)
| _ -> hpred in
let sigma' = List.map ~f:(do_hpred false) prop.Prop.sigma in
@ -462,7 +462,7 @@ let execute___objc_counter_update
(* This is the case as a call f(o) it's translates as n$1=*&o; f(n$1) *)
(* n$2 = *n$1.hidden *)
let tmp = Ident.create_fresh Ident.knormal in
let hidden_field = Exp.Lfield (lexp, Ident.fieldname_hidden, typ) in
let hidden_field = Exp.Lfield (lexp, Fieldname.hidden, typ) in
let counter_to_tmp = Sil.Load (tmp, hidden_field, typ, loc) in
(* *n$1.hidden = (n$2 +/- delta) *)
let update_counter =

@ -469,7 +469,7 @@ let discover_para_candidates tenv p =
let edges = ref [] in
let add_edge edg = edges := edg :: !edges in
let get_edges_strexp rec_flds root se =
let is_rec_fld fld = List.exists ~f:(Ident.equal_fieldname fld) rec_flds in
let is_rec_fld fld = List.exists ~f:(Fieldname.equal fld) rec_flds in
match se with
| Sil.Eexp _ | Sil.Earray _ -> ()
| Sil.Estruct (fsel, _) ->
@ -505,7 +505,7 @@ let discover_para_dll_candidates tenv p =
let edges = ref [] in
let add_edge edg = (edges := edg :: !edges) in
let get_edges_strexp rec_flds root se =
let is_rec_fld fld = List.exists ~f:(Ident.equal_fieldname fld) rec_flds in
let is_rec_fld fld = List.exists ~f:(Fieldname.equal fld) rec_flds in
match se with
| Sil.Eexp _ | Sil.Earray _ -> ()
| Sil.Estruct (fsel, _) ->
@ -882,7 +882,7 @@ let get_cycle root prop =
match e, e' with
| Sil.Eexp (e, _), Sil.Eexp (e', _) ->
L.d_str ("("^(Exp.to_string e)^": "^(Typ.to_string t)^", "
^(Ident.fieldname_to_string f)^", "^(Exp.to_string e')^")")
^(Fieldname.to_string f)^", "^(Exp.to_string e')^")")
| _ -> ()) cyc;
L.d_strln "") in
(* Perform a dfs of a graph stopping when e_root is reached.
@ -927,7 +927,7 @@ let should_raise_objc_leak hpred =
match hpred with
| Sil.Hpointsto(_, Sil.Estruct((fn, Sil.Eexp( (Exp.Const (Const.Cint i)), _)):: _, _),
Exp.Sizeof (typ, _, _))
when Ident.fieldname_is_hidden fn && IntLit.gt i IntLit.zero (* counter > 0 *) ->
when Fieldname.is_hidden fn && IntLit.gt i IntLit.zero (* counter > 0 *) ->
Mleak_buckets.should_raise_objc_leak typ
| _ -> None
@ -990,7 +990,7 @@ let cycle_has_weak_or_unretained_or_assign_field tenv cycle =
let get_item_annotation (t: Typ.t) fn =
match t with
| Tstruct name -> (
let equal_fn (fn', _, _) = Ident.equal_fieldname fn fn' in
let equal_fn (fn', _, _) = Fieldname.equal fn fn' in
match Tenv.lookup tenv name with
| Some { fields; statics } -> (
List.find ~f:equal_fn (fields @ statics) |>

@ -58,7 +58,7 @@ module StrexpMatch : sig
end = struct
(** syntactic offset *)
type syn_offset = Field of Ident.fieldname * Typ.t | Index of Exp.t
type syn_offset = Field of Fieldname.t * Typ.t | Index of Exp.t
(** path through an Estruct *)
type path = Exp.t * (syn_offset list)
@ -77,9 +77,9 @@ end = struct
match Tenv.lookup tenv name with
| Some { fields } ->
let se' =
snd (List.find_exn ~f:(fun (f', _) -> Ident.equal_fieldname f' fld) fsel) in
snd (List.find_exn ~f:(fun (f', _) -> Fieldname.equal f' fld) fsel) in
let t' =
snd3 (List.find_exn ~f:(fun (f', _, _) -> Ident.equal_fieldname f' fld) fields) in
snd3 (List.find_exn ~f:(fun (f', _, _) -> Fieldname.equal f' fld) fields) in
get_strexp_at_syn_offsets tenv se' t' syn_offs'
| None ->
fail ()
@ -98,14 +98,14 @@ end = struct
| Sil.Estruct (fsel, inst), Tstruct name, Field (fld, _) :: syn_offs' -> (
match Tenv.lookup tenv name with
| Some { fields } ->
let se' = snd (List.find_exn ~f:(fun (f', _) -> Ident.equal_fieldname f' fld) fsel) in
let se' = snd (List.find_exn ~f:(fun (f', _) -> Fieldname.equal f' fld) fsel) in
let t' = (fun (_,y,_) -> y)
(List.find_exn ~f:(fun (f', _, _) ->
Ident.equal_fieldname f' fld) fields) in
Fieldname.equal f' fld) fields) in
let se_mod = replace_strexp_at_syn_offsets tenv se' t' syn_offs' update in
let fsel' =
List.map ~f:(fun (f'', se'') ->
if Ident.equal_fieldname f'' fld then (fld, se_mod) else (f'', se'')
if Fieldname.equal f'' fld then (fld, se_mod) else (f'', se'')
) fsel in
Sil.Estruct (fsel', inst)
| None ->
@ -179,12 +179,12 @@ end = struct
| [] -> ()
| (f, se) :: fsel' ->
begin
match List.find ~f:(fun (f', _, _) -> Ident.equal_fieldname f' f) ftal with
match List.find ~f:(fun (f', _, _) -> Fieldname.equal f' f) ftal with
| Some (_, t, _) ->
find_offset_sexp sigma_other hpred root ((Field (f, typ)) :: offs) se t
| None ->
L.d_strln
("Can't find field " ^ (Ident.fieldname_to_string f) ^ " in StrexpMatch.find")
("Can't find field " ^ (Fieldname.to_string f) ^ " in StrexpMatch.find")
end;
find_offset_fsel sigma_other hpred root offs fsel' ftal typ
and find_offset_esel sigma_other hpred root offs esel t = match esel with

@ -953,7 +953,7 @@ let rec exp_partial_join (e1: Exp.t) (e2: Exp.t) : Exp.t =
if not (Pvar.equal pvar1 pvar2) then (L.d_strln "failure reason 25"; raise Sil.JoinFail)
else e1
| Exp.Lfield(e1, f1, t1), Exp.Lfield(e2, f2, _) ->
if not (Ident.equal_fieldname f1 f2) then (L.d_strln "failure reason 26"; raise Sil.JoinFail)
if not (Fieldname.equal f1 f2) then (L.d_strln "failure reason 26"; raise Sil.JoinFail)
else Exp.Lfield(exp_partial_join e1 e2, f1, t1) (* should be t1 = t2 *)
| Exp.Lindex(e1, e1'), Exp.Lindex(e2, e2') ->
let e1'' = exp_partial_join e1 e2 in
@ -1036,7 +1036,7 @@ let rec exp_partial_meet (e1: Exp.t) (e2: Exp.t) : Exp.t =
if not (Pvar.equal pvar1 pvar2) then (L.d_strln "failure reason 35"; raise Sil.JoinFail)
else e1
| Exp.Lfield(e1, f1, t1), Exp.Lfield(e2, f2, _) ->
if not (Ident.equal_fieldname f1 f2) then (L.d_strln "failure reason 36"; raise Sil.JoinFail)
if not (Fieldname.equal f1 f2) then (L.d_strln "failure reason 36"; raise Sil.JoinFail)
else Exp.Lfield(exp_partial_meet e1 e2, f1, t1) (* should be t1 = t2 *)
| Exp.Lindex(e1, e1'), Exp.Lindex(e2, e2') ->
let e1'' = exp_partial_meet e1 e2 in
@ -1063,7 +1063,7 @@ let rec strexp_partial_join mode (strexp1: Sil.strexp) (strexp2: Sil.strexp) : S
| JoinState.Post -> Sil.Estruct (List.rev acc, inst)
end
| (fld1, se1):: fld_se_list1', (fld2, se2):: fld_se_list2' ->
let comparison = Ident.compare_fieldname fld1 fld2 in
let comparison = Fieldname.compare fld1 fld2 in
if Int.equal comparison 0 then
let strexp' = strexp_partial_join mode se1 se2 in
let fld_se_list_new = (fld1, strexp') :: acc in
@ -1127,7 +1127,7 @@ let rec strexp_partial_meet (strexp1: Sil.strexp) (strexp2: Sil.strexp) : Sil.st
| _, [] ->
Sil.Estruct (construct Lhs acc fld_se_list1, inst)
| (fld1, se1):: fld_se_list1', (fld2, se2):: fld_se_list2' ->
let comparison = Ident.compare_fieldname fld1 fld2 in
let comparison = Fieldname.compare fld1 fld2 in
if comparison < 0 then
let se' = strexp_construct_fresh Lhs se1 in
let acc_new = (fld1, se'):: acc in

@ -66,7 +66,7 @@ type dotty_node =
(* Dotpointsto(coo,e,c): basic memory cell box for expression e at coordinate coo and color c *)
| Dotpointsto of coordinate * Exp.t * string
(* Dotstruct(coo,e,l,c): struct box for expression e with field list l at coordinate coo and color c *)
| Dotstruct of coordinate * Exp.t * (Ident.fieldname * Sil.strexp) list * string * Exp.t
| Dotstruct of coordinate * Exp.t * (Fieldname.t * Sil.strexp) list * string * Exp.t
(* Dotarray(coo,e1,e2,l,t,c): array box for expression e1 with field list l at coordinate coo and color c*)
(* e2 is the len and t is the type *)
| Dotarray of coordinate * Exp.t * Exp.t * (Exp.t * Sil.strexp) list * Typ.t * string
@ -145,8 +145,8 @@ let rec strexp_to_string pe coo f se =
and struct_to_dotty_str pe coo f ls : unit =
match ls with
| [] -> ()
| (fn, se)::[]-> F.fprintf f "{ <%s%iL%i> %s: %a } " (Ident.fieldname_to_string fn) coo.id coo.lambda (Ident.fieldname_to_string fn) (strexp_to_string pe coo) se
| (fn, se):: ls'-> F.fprintf f " { <%s%iL%i> %s: %a } | %a" (Ident.fieldname_to_string fn) coo.id coo.lambda (Ident.fieldname_to_string fn) (strexp_to_string pe coo) se (struct_to_dotty_str pe coo) ls'
| (fn, se)::[]-> F.fprintf f "{ <%s%iL%i> %s: %a } " (Fieldname.to_string fn) coo.id coo.lambda (Fieldname.to_string fn) (strexp_to_string pe coo) se
| (fn, se):: ls'-> F.fprintf f " { <%s%iL%i> %s: %a } | %a" (Fieldname.to_string fn) coo.id coo.lambda (Fieldname.to_string fn) (strexp_to_string pe coo) se (struct_to_dotty_str pe coo) ls'
and get_contents_sexp pe coo f se =
match se with
@ -387,7 +387,7 @@ let in_cycle cycle edge =
| Some cycle' ->
let (fn, se) = edge in
List.exists
~f:(fun (_,fn',se') -> Ident.equal_fieldname fn fn' && Sil.equal_strexp se se')
~f:(fun (_,fn',se') -> Fieldname.equal fn fn' && Sil.equal_strexp se se')
cycle'
| _ -> false
@ -406,7 +406,7 @@ let rec compute_target_struct_fields dotnodes list_fld p f lambda cycle =
if is_nil e p then begin
let n'= make_nil_node lambda in
if !print_full_prop then
[(LinkStructToExp, Ident.fieldname_to_string fn, n',"")]
[(LinkStructToExp, Fieldname.to_string fn, n',"")]
else []
end else
let nodes_e = select_nodes_exp_lambda dotnodes e lambda in
@ -414,7 +414,7 @@ let rec compute_target_struct_fields dotnodes list_fld p f lambda cycle =
| [] ->
(match box_dangling e with
| None -> []
| Some n' -> [(LinkStructToExp, Ident.fieldname_to_string fn, n',"")]
| Some n' -> [(LinkStructToExp, Fieldname.to_string fn, n',"")]
)
| [node] | [Dotpointsto _ ; node] | [node; Dotpointsto _] ->
let n = get_coordinate_id node in
@ -423,9 +423,9 @@ let rec compute_target_struct_fields dotnodes list_fld p f lambda cycle =
let link_kind = if (in_cycle cycle (fn, se)) && (not !print_full_prop) then
LinkRetainCycle
else LinkStructToStruct in
[(link_kind, Ident.fieldname_to_string fn, n, e_no_special_char)]
[(link_kind, Fieldname.to_string fn, n, e_no_special_char)]
end else
[(LinkStructToExp, Ident.fieldname_to_string fn, n,"")]
[(LinkStructToExp, Fieldname.to_string fn, n,"")]
| _ -> (* by construction there must be at most 2 nodes for an expression*)
L.out "@\n Too many nodes! Error! @\n@.@."; assert false)
| Sil.Estruct (_, _) -> [] (* inner struct are printed by print_struc function *)
@ -1244,7 +1244,7 @@ let rec compute_target_nodes_from_sexp nodes se prop field_lab =
(match lfld with
| [] -> []
| (fn, se2):: l' ->
compute_target_nodes_from_sexp nodes se2 prop (Ident.fieldname_to_string fn) @
compute_target_nodes_from_sexp nodes se2 prop (Fieldname.to_string fn) @
compute_target_nodes_from_sexp nodes (Sil.Estruct (l', inst)) prop ""
)
| Sil.Earray (len, lie, inst) ->
@ -1315,7 +1315,7 @@ let rec pointsto_contents_to_xml (co: Sil.strexp) : Io_infer.Xml.node =
| Sil.Eexp (e, _) ->
Io_infer.Xml.create_tree "cell" [("content-value", exp_to_xml_string e)] []
| Sil.Estruct (fel, _) ->
let f (fld, exp) = Io_infer.Xml.create_tree "struct-field" [("id", Ident.fieldname_to_string fld)] [(pointsto_contents_to_xml exp)] in
let f (fld, exp) = Io_infer.Xml.create_tree "struct-field" [("id", Fieldname.to_string fld)] [(pointsto_contents_to_xml exp)] in
Io_infer.Xml.create_tree "struct" [] (List.map ~f fel)
| Sil.Earray (len, nel, _) ->
let f (e, se) = Io_infer.Xml.create_tree "array-element" [("index", exp_to_xml_string e)] [pointsto_contents_to_xml se] in

@ -23,7 +23,7 @@ type kind_of_dotty_prop =
val reset_proposition_counter : unit -> unit
val pp_dotty : Format.formatter -> kind_of_dotty_prop -> Prop.normal Prop.t ->
((Sil.strexp * Typ.t) * Ident.fieldname * Sil.strexp) list option -> unit
((Sil.strexp * Typ.t) * Fieldname.t * Sil.strexp) list option -> unit
(** {2 Sets and lists of propositions} *)
@ -44,10 +44,10 @@ val pp_speclist_dotty_file : DB.filename -> Prop.normal Specs.spec list -> unit
(* create a dotty file with a single proposition *)
val dotty_prop_to_dotty_file : string -> Prop.normal Prop.t ->
((Sil.strexp * Typ.t) * Ident.fieldname * Sil.strexp) list -> unit
((Sil.strexp * Typ.t) * Fieldname.t * Sil.strexp) list -> unit
val dotty_prop_to_str : Prop.normal Prop.t ->
((Sil.strexp * Typ.t) * Ident.fieldname * Sil.strexp) list -> string option
((Sil.strexp * Typ.t) * Fieldname.t * Sil.strexp) list -> string option
(** reset the counter used for node and heap identifiers *)
val reset_node_counter : unit -> unit

@ -35,7 +35,7 @@ let is_vector_method pname =
is_method_of_objc_cpp_class pname [vector_class]
let is_special_field class_names field_name_opt field =
let complete_fieldname = Ident.fieldname_to_complete_string field in
let complete_fieldname = Fieldname.to_complete_string field in
let field_ok =
match field_name_opt with
| Some field_name -> String.is_substring ~substring:field_name complete_fieldname
@ -315,7 +315,7 @@ and _exp_lv_dexp tenv (_seen : Exp.Set.t) node e : DExp.t option =
begin
L.d_str "exp_lv_dexp: Lfield with var ";
Sil.d_exp (Exp.Var id);
L.d_str (" " ^ Ident.fieldname_to_string f);
L.d_str (" " ^ Fieldname.to_string f);
L.d_ln ()
end;
(match _find_normal_variable_load tenv seen node id with
@ -326,7 +326,7 @@ and _exp_lv_dexp tenv (_seen : Exp.Set.t) node e : DExp.t option =
begin
L.d_str "exp_lv_dexp: Lfield ";
Sil.d_exp e1;
L.d_str (" " ^ Ident.fieldname_to_string f);
L.d_str (" " ^ Fieldname.to_string f);
L.d_ln ()
end;
(match _exp_lv_dexp tenv seen node e1 with
@ -374,7 +374,7 @@ and _exp_rv_dexp tenv (_seen : Exp.Set.t) node e : DExp.t option =
begin
L.d_str "exp_rv_dexp: Lfield ";
Sil.d_exp e1;
L.d_str (" " ^ Ident.fieldname_to_string f);
L.d_str (" " ^ Fieldname.to_string f);
L.d_ln ()
end;
(match _exp_rv_dexp tenv seen node e1 with
@ -582,7 +582,7 @@ let vpath_find tenv prop _exp : DExp.t option * Typ.t option =
| Exp.Sizeof (Tstruct name, _, _) -> (
match Tenv.lookup tenv name with
| Some {fields} ->
List.find ~f:(fun (f', _, _) -> Ident.equal_fieldname f' f) fields |>
List.find ~f:(fun (f', _, _) -> Fieldname.equal f' f) fields |>
Option.map ~f:snd3
| _ ->
None
@ -679,10 +679,10 @@ let explain_dexp_access prop dexp is_nullable =
| [] ->
if verbose
then
(L.d_strln ("lookup_fld: can't find field " ^ Ident.fieldname_to_string f));
(L.d_strln ("lookup_fld: can't find field " ^ Fieldname.to_string f));
None
| (f1, se):: fsel' ->
if Ident.equal_fieldname f1 f then Some se
if Fieldname.equal f1 f then Some se
else lookup_fld fsel' f in
let rec lookup_esel esel e = match esel with
| [] ->
@ -944,7 +944,7 @@ type pvar_off =
| Fpvar
(* value obtained by dereferencing the pvar and following a sequence of fields *)
| Fstruct of Ident.fieldname list
| Fstruct of Fieldname.t list
let dexp_apply_pvar_off dexp pvar_off =
let rec add_ddot de = function

@ -42,8 +42,8 @@ val find_boolean_assignment : Procdesc.Node.t -> Pvar.t -> bool -> Procdesc.Node
val exp_rv_dexp : Tenv.t -> Procdesc.Node.t -> Exp.t -> DecompiledExp.t option
(** Produce a description of a persistent reference to an Android Context *)
val explain_context_leak : Typ.Procname.t -> Typ.t -> Ident.fieldname ->
(Ident.fieldname option * Typ.t) list -> Localise.error_desc
val explain_context_leak : Typ.Procname.t -> Typ.t -> Fieldname.t ->
(Fieldname.t option * Typ.t) list -> Localise.error_desc
(** Produce a description of a mismatch between an allocation function and a deallocation function *)
val explain_allocation_mismatch :
@ -103,7 +103,7 @@ val explain_return_statement_missing : Location.t -> Localise.error_desc
(** explain a retain cycle *)
val explain_retain_cycle :
((Sil.strexp * Typ.t) * Ident.fieldname * Sil.strexp) list ->
((Sil.strexp * Typ.t) * Fieldname.t * Sil.strexp) list ->
Location.t -> string option -> Localise.error_desc
(** explain unary minus applied to unsigned expression *)
@ -136,7 +136,7 @@ val warning_err : Location.t -> ('a, Format.formatter, unit) format -> 'a
(* offset of an expression found following a program variable *)
type pvar_off =
| Fpvar (* value of a pvar *)
| Fstruct of Ident.fieldname list (* value obtained by dereferencing the pvar and following a sequence of fields *)
| Fstruct of Fieldname.t list (* value obtained by dereferencing the pvar and following a sequence of fields *)
(** Find a program variable whose value is [exp] or pointing to a struct containing [exp] *)
val find_with_exp : 'a Prop.t -> Exp.t -> (Pvar.t * pvar_off) option

@ -74,7 +74,7 @@ let rec exp_match e1 sub vars e2 : (Sil.subst * Ident.t list) option =
check_equal sub vars e1 e2
| Exp.Lvar _, _ | _, Exp.Lvar _ ->
check_equal sub vars e1 e2
| Exp.Lfield(e1', fld1, _), Exp.Lfield(e2', fld2, _) when (Ident.equal_fieldname fld1 fld2) ->
| Exp.Lfield(e1', fld1, _), Exp.Lfield(e2', fld2, _) when (Fieldname.equal fld1 fld2) ->
exp_match e1' sub vars e2'
| Exp.Lfield _, _ | _, Exp.Lfield _ ->
None
@ -121,7 +121,7 @@ and fsel_match fsel1 sub vars fsel2 =
if (Config.abs_struct <= 0) then None
else Some (sub, vars) (* This can lead to great information loss *)
| (fld1, se1') :: fsel1', (fld2, se2') :: fsel2' ->
let n = Ident.compare_fieldname fld1 fld2 in
let n = Fieldname.compare fld1 fld2 in
if Int.equal n 0 then begin
match strexp_match se1' sub vars se2' with
| None -> None
@ -512,7 +512,7 @@ and generate_todos_from_fel mode todos fel1 fel2 =
| _, [] ->
if equal_iso_mode mode LFieldForget then Some todos else None
| (fld1, strexp1) :: fel1', (fld2, strexp2) :: fel2' ->
let n = Ident.compare_fieldname fld1 fld2 in
let n = Fieldname.compare fld1 fld2 in
if Int.equal n 0 then
begin
match generate_todos_from_strexp mode todos strexp1 strexp2 with

@ -1250,7 +1250,7 @@ module Normalize = struct
(* n1-e1 == n2 -> e1==n1-n2 *)
(e1, Exp.int (n1 -- n2))
| Lfield (e1', fld1, _), Lfield (e2', fld2, _) ->
if Ident.equal_fieldname fld1 fld2
if Fieldname.equal fld1 fld2
then normalize_eq (e1', e2')
else eq
| Lindex (e1', idx1), Lindex (e2', idx2) ->
@ -1318,7 +1318,7 @@ module Normalize = struct
let fld_cnts' =
List.map ~f:(fun (fld, cnt) ->
fld, strexp_normalize tenv sub cnt) fld_cnts in
let fld_cnts'' = List.sort ~cmp:[%compare: Ident.fieldname * Sil.strexp] fld_cnts' in
let fld_cnts'' = List.sort ~cmp:[%compare: Fieldname.t * Sil.strexp] fld_cnts' in
Estruct (fld_cnts'', inst)
end
| Earray (len, idx_cnts, inst) ->
@ -2438,7 +2438,7 @@ let rec strexp_gc_fields (fav: Sil.fav) (se : Sil.strexp) =
let fsel' =
let fselo' = List.filter ~f:(function | (_, Some _) -> true | _ -> false) fselo in
List.map ~f:(function (f, seo) -> (f, unSome seo)) fselo' in
if [%compare.equal: (Ident.fieldname * Sil.strexp) list] fsel fsel' then Some se
if [%compare.equal: (Fieldname.t * Sil.strexp) list] fsel fsel' then Some se
else Some (Sil.Estruct (fsel', inst))
| Earray _ ->
Some se

@ -143,7 +143,7 @@ let rec compute_sexp_diff (se1: Sil.strexp) (se2: Sil.strexp) : Obj.t list = mat
and compute_fsel_diff fsel1 fsel2 : Obj.t list = match fsel1, fsel2 with
| ((f1, se1):: fsel1'), (((f2, se2) as x):: fsel2') ->
(match Ident.compare_fieldname f1 f2 with
(match Fieldname.compare f1 f2 with
| n when n < 0 -> compute_fsel_diff fsel1' fsel2
| 0 -> compute_sexp_diff se1 se2 @ compute_fsel_diff fsel1' fsel2'
| _ -> (Obj.repr x) :: compute_fsel_diff fsel1 fsel2')

@ -1224,7 +1224,7 @@ let exp_imply tenv calc_missing subs e1_in e2_in : subst2 =
raise (IMPL_EXC ("expressions not equal", subs, (EXC_FALSE_EXPS (e1, e2))))
| e1, Exp.Const _ ->
raise (IMPL_EXC ("lhs not constant", subs, (EXC_FALSE_EXPS (e1, e2))))
| Exp.Lfield(e1, fd1, _), Exp.Lfield(e2, fd2, _) when Ident.equal_fieldname fd1 fd2 ->
| Exp.Lfield(e1, fd1, _), Exp.Lfield(e2, fd2, _) when Fieldname.equal fd1 fd2 ->
do_imply subs e1 e2
| Exp.Lindex(e1, f1), Exp.Lindex(e2, f2) ->
do_imply (do_imply subs e1 e2) f1 f2
@ -1245,7 +1245,7 @@ let path_to_id path =
| Exp.Lfield (e, fld, _) ->
(match f e with
| None -> None
| Some s -> Some (s ^ "_" ^ (Ident.fieldname_to_string fld)))
| Some s -> Some (s ^ "_" ^ (Fieldname.to_string fld)))
| Exp.Lindex (e, ind) ->
(match f e with
| None -> None
@ -1341,13 +1341,13 @@ let rec sexp_imply tenv source calc_index_frame calc_missing subs se1 se2 typ2 :
d_impl_err ("sexp_imply not implemented", subs, (EXC_FALSE_SEXPS (se1, se2)));
raise (Exceptions.Abduction_case_not_implemented __POS__)
and struct_imply tenv source calc_missing subs fsel1 fsel2 typ2 : subst2 * ((Ident.fieldname * Sil.strexp) list) * ((Ident.fieldname * Sil.strexp) list) =
and struct_imply tenv source calc_missing subs fsel1 fsel2 typ2 : subst2 * ((Fieldname.t * Sil.strexp) list) * ((Fieldname.t * Sil.strexp) list) =
let lookup = Tenv.lookup tenv in
match fsel1, fsel2 with
| _, [] -> subs, fsel1, []
| (f1, se1) :: fsel1', (f2, se2) :: fsel2' ->
begin
match Ident.compare_fieldname f1 f2 with
match Fieldname.compare f1 f2 with
| 0 ->
let typ' = Typ.Struct.fld_typ ~lookup ~default:Typ.Tvoid f2 typ2 in
let subs', se_frame, se_missing =
@ -1972,7 +1972,7 @@ and sigma_imply tenv calc_index_frame calc_missing subs prop1 sigma2 : (subst2 *
(Exp.int len, [(index, Sil.Eexp (Exp.zero, Sil.inst_none))], Sil.inst_none)
| Config.Java ->
let mk_fld_sexp s =
let fld = Ident.create_fieldname (Mangled.from_string s) 0 in
let fld = Fieldname.create (Mangled.from_string s) 0 in
let se = Sil.Eexp (Exp.Var (Ident.create_fresh Ident.kprimed), Sil.Inone) in
(fld, se) in
let fields = ["java.lang.String.count"; "java.lang.String.hash"; "java.lang.String.offset"; "java.lang.String.value"] in
@ -1989,7 +1989,7 @@ and sigma_imply tenv calc_index_frame calc_missing subs prop1 sigma2 : (subst2 *
let root = Exp.Const (Const.Cclass (Ident.string_to_name s)) in
let sexp = (* TODO: add appropriate fields *)
Sil.Estruct
([(Ident.create_fieldname (Mangled.from_string "java.lang.Class.name") 0,
([(Fieldname.create (Mangled.from_string "java.lang.Class.name") 0,
Sil.Eexp ((Exp.Const (Const.Cstr s), Sil.Inone)))], Sil.inst_none) in
let class_texp =
let class_type = Typ.Name.Java.from_string "java.lang.Class" in

@ -107,7 +107,7 @@ let rec create_struct_values pname tenv orig_prop footprint_part kind max_stamp
match Tenv.lookup tenv name with
| Some ({ fields; statics; } as struct_typ) -> (
match List.find
~f:(fun (f', _, _) -> Ident.equal_fieldname f f')
~f:(fun (f', _, _) -> Fieldname.equal f f')
(fields @ statics) with
| Some (_, t', _) ->
let atoms', se', res_t' =
@ -115,7 +115,7 @@ let rec create_struct_values pname tenv orig_prop footprint_part kind max_stamp
pname tenv orig_prop footprint_part kind max_stamp t' off' inst in
let se = Sil.Estruct ([(f, se')], inst) in
let replace_typ_of_f (f', t', a') =
if Ident.equal_fieldname f f' then (f, res_t', a') else (f', t', a') in
if Fieldname.equal f f' then (f, res_t', a') else (f', t', a') in
let fields' =
List.sort ~cmp:Typ.Struct.compare_field (List.map ~f:replace_typ_of_f fields) in
ignore (Tenv.mk_struct tenv ~default:struct_typ ~fields:fields' name) ;
@ -209,22 +209,22 @@ let rec _strexp_extend_values
| (Off_fld (f, _)) :: off', Sil.Estruct (fsel, inst'), Tstruct name -> (
match Tenv.lookup tenv name with
| Some ({ fields; statics; } as struct_typ) -> (
match List.find ~f:(fun (f', _, _) -> Ident.equal_fieldname f f') (fields @ statics) with
match List.find ~f:(fun (f', _, _) -> Fieldname.equal f f') (fields @ statics) with
| Some (_, typ', _) -> (
match List.find ~f:(fun (f', _) -> Ident.equal_fieldname f f') fsel with
match List.find ~f:(fun (f', _) -> Fieldname.equal f f') fsel with
| Some (_, se') ->
let atoms_se_typ_list' =
_strexp_extend_values
pname tenv orig_prop footprint_part kind max_stamp se' typ' off' inst in
let replace acc (res_atoms', res_se', res_typ') =
let replace_fse ((f1, _) as ft1) =
if Ident.equal_fieldname f1 f then (f1, res_se') else ft1 in
if Fieldname.equal f1 f then (f1, res_se') else ft1 in
let res_fsel' =
List.sort
~cmp:[%compare: Ident.fieldname * Sil.strexp]
~cmp:[%compare: Fieldname.t * Sil.strexp]
(List.map ~f:replace_fse fsel) in
let replace_fta ((f1, _, a1) as fta1) =
if Ident.equal_fieldname f f1 then (f1, res_typ', a1) else fta1 in
if Fieldname.equal f f1 then (f1, res_typ', a1) else fta1 in
let fields' =
List.sort ~cmp:Typ.Struct.compare_field (List.map ~f:replace_fta fields) in
ignore (Tenv.mk_struct tenv ~default:struct_typ ~fields:fields' name) ;
@ -235,9 +235,9 @@ let rec _strexp_extend_values
create_struct_values
pname tenv orig_prop footprint_part kind max_stamp typ' off' inst in
let res_fsel' =
List.sort ~cmp:[%compare: Ident.fieldname * Sil.strexp] ((f, se'):: fsel) in
List.sort ~cmp:[%compare: Fieldname.t * Sil.strexp] ((f, se'):: fsel) in
let replace_fta (f', t', a') =
if Ident.equal_fieldname f' f then (f, res_typ', a') else (f', t', a') in
if Fieldname.equal f' f then (f, res_typ', a') else (f', t', a') in
let fields' =
List.sort ~cmp:Typ.Struct.compare_field (List.map ~f:replace_fta fields) in
ignore (Tenv.mk_struct tenv ~default:struct_typ ~fields:fields' name) ;
@ -477,7 +477,7 @@ let prop_iter_check_fields_ptsto_shallow tenv iter lexp =
| (Sil.Off_fld (fld, _)):: off' ->
(match se with
| Sil.Estruct (fsel, _) ->
(match List.find ~f:(fun (fld', _) -> Ident.equal_fieldname fld fld') fsel with
(match List.find ~f:(fun (fld', _) -> Fieldname.equal fld fld') fsel with
| Some (_, se') ->
check_offset se' off'
| None -> Some fld)
@ -711,7 +711,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc =
match extract_guarded_by_str item_annot with
| Some "this" ->
(* expand "this" into <classname>.this *)
Some (Printf.sprintf "%s.this" (Ident.java_fieldname_get_class fld))
Some (Printf.sprintf "%s.this" (Fieldname.java_get_class fld))
| guarded_by_str_opt ->
guarded_by_str_opt
end
@ -722,8 +722,8 @@ let add_guarded_by_constraints tenv prop lexp pdesc =
let is_guarded_by_fld guarded_by_str fld _ =
(* this comparison needs to be somewhat fuzzy, since programmers are free to write
@GuardedBy("mLock"), @GuardedBy("MyClass.mLock"), or use other conventions *)
String.equal (Ident.fieldname_to_flat_string fld) guarded_by_str ||
String.equal (Ident.fieldname_to_string fld) guarded_by_str in
String.equal (Fieldname.to_flat_string fld) guarded_by_str ||
String.equal (Fieldname.to_string fld) guarded_by_str in
let get_fld_strexp_and_typ typ f flds =
let match_one (fld, strexp) =
@ -777,7 +777,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc =
nothing we can do to disambiguate them. *)
get_fld_strexp_and_typ
typ
(fun f _ -> Ident.java_fieldname_is_outer_instance f)
(fun f _ -> Fieldname.java_is_outer_instance f)
flds
| None ->
(* can't find an exact match. try a different convention. *)
@ -834,7 +834,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc =
(Attribute.get_for_exp tenv prop guarded_by_exp) in
let guardedby_is_self_referential =
String.equal "itself" (String.lowercase guarded_by_str) ||
String.is_suffix ~suffix:guarded_by_str (Ident.fieldname_to_string accessed_fld) in
String.is_suffix ~suffix:guarded_by_str (Fieldname.to_string accessed_fld) in
let proc_has_suppress_guarded_by_annot pdesc =
match extract_suppress_warnings_str (Annotations.pdesc_get_return_annot pdesc) with
| Some suppression_str->
@ -854,7 +854,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc =
List.exists
~f:(fun (fld, strexp) -> match strexp with
| Sil.Eexp (rhs_exp, _) ->
Exp.equal exp rhs_exp && not (Ident.equal_fieldname fld accessed_fld)
Exp.equal exp rhs_exp && not (Fieldname.equal fld accessed_fld)
| _ ->
false)
flds
@ -1133,7 +1133,7 @@ let type_at_offset tenv texp off =
| (Off_fld (f, _)) :: off', Tstruct name -> (
match Tenv.lookup tenv name with
| Some { fields } -> (
match List.find ~f:(fun (f', _, _) -> Ident.equal_fieldname f f') fields with
match List.find ~f:(fun (f', _, _) -> Fieldname.equal f f') fields with
| Some (_, typ', _) -> strip_offset off' typ'
| None -> None
)
@ -1189,7 +1189,7 @@ let rec iter_rearrange
(* access through field: get the struct type from the field *)
if Config.trace_rearrange then begin
L.d_increase_indent 1;
L.d_str "iter_rearrange: root of lexp accesses field "; L.d_strln (Ident.fieldname_to_string f);
L.d_str "iter_rearrange: root of lexp accesses field "; L.d_strln (Fieldname.to_string f);
L.d_str " struct type from field: "; Typ.d_full struct_typ; L.d_ln();
L.d_decrease_indent 1;
L.d_ln();
@ -1318,7 +1318,7 @@ let is_strexp_pt_fld_with_annot tenv obj_str is_annotation typ deref_exp (fld,
| Sil.Eexp (Exp.Var _ as exp, _) when Exp.equal exp deref_exp ->
let has_annot = fld_has_annot fld in
if has_annot then
obj_str := Some (Ident.fieldname_to_simplified_string fld);
obj_str := Some (Fieldname.to_simplified_string fld);
has_annot
| _ -> true

@ -18,7 +18,7 @@ module F = Format
let rec fldlist_assoc fld = function
| [] -> raise Not_found
| (fld', x, _):: l -> if Ident.equal_fieldname fld fld' then x else fldlist_assoc fld l
| (fld', x, _):: l -> if Fieldname.equal fld fld' then x else fldlist_assoc fld l
let unroll_type tenv (typ: Typ.t) (off: Sil.offset) =
let fail fld_to_string fld =
@ -32,10 +32,10 @@ let unroll_type tenv (typ: Typ.t) (off: Sil.offset) =
match Tenv.lookup tenv name with
| Some { fields; statics } -> (
try fldlist_assoc fld (fields @ statics)
with Not_found -> fail Ident.fieldname_to_string fld
with Not_found -> fail Fieldname.to_string fld
)
| None ->
fail Ident.fieldname_to_string fld
fail Fieldname.to_string fld
)
| Tarray (typ', _), Off_index _ ->
typ'
@ -102,7 +102,7 @@ let rec apply_offlist
let is_hidden_field () =
match State.get_instr () with
| Some (Sil.Load (_, Exp.Lfield (_, fieldname, _), _, _)) ->
Ident.fieldname_is_hidden fieldname
Fieldname.is_hidden fieldname
| _ -> false in
let inst_new = match inst with
| Sil.Ilookup when inst_is_uninitialized inst_curr && not (is_hidden_field()) ->
@ -142,17 +142,17 @@ let rec apply_offlist
match Tenv.lookup tenv name with
| Some ({fields} as struct_typ) -> (
let t' = unroll_type tenv typ (Sil.Off_fld (fld, fld_typ)) in
match List.find ~f:(fun fse -> Ident.equal_fieldname fld (fst fse)) fsel with
match List.find ~f:(fun fse -> Fieldname.equal fld (fst fse)) fsel with
| Some (_, se') ->
let res_e', res_se', res_t', res_pred_insts_op' =
apply_offlist
pdesc tenv p fp_root nullify_struct
(root_lexp, se', t') offlist' f inst lookup_inst in
let replace_fse fse =
if Ident.equal_fieldname fld (fst fse) then (fld, res_se') else fse in
if Fieldname.equal fld (fst fse) then (fld, res_se') else fse in
let res_se = Sil.Estruct (List.map ~f:replace_fse fsel, inst') in
let replace_fta (f, t, a) =
if Ident.equal_fieldname fld f then (fld, res_t', a) else (f, t, a) in
if Fieldname.equal fld f then (fld, res_t', a) else (f, t, a) in
let fields' = List.map ~f:replace_fta fields in
ignore (Tenv.mk_struct tenv ~default:struct_typ ~fields:fields' name) ;
(res_e', res_se, typ, res_pred_insts_op')
@ -1524,7 +1524,7 @@ and check_variadic_sentinel_if_present
and sym_exec_objc_getter field_name ret_typ tenv ret_id pdesc pname loc args prop =
L.d_strln ("No custom getter found. Executing the ObjC builtin getter with ivar "^
(Ident.fieldname_to_string field_name)^".");
(Fieldname.to_string field_name)^".");
let ret_id =
match ret_id with
| Some (ret_id, _) -> ret_id
@ -1538,7 +1538,7 @@ and sym_exec_objc_getter field_name ret_typ tenv ret_id pdesc pname loc args pro
and sym_exec_objc_setter field_name _ tenv _ pdesc pname loc args prop =
L.d_strln ("No custom setter found. Executing the ObjC builtin setter with ivar "^
(Ident.fieldname_to_string field_name)^".");
(Fieldname.to_string field_name)^".");
match args with
| (lexp1, (Typ.Tstruct _ as typ1 | Tptr (typ1, _))) :: (lexp2, typ2) :: _ ->
let field_access_exp = Exp.Lfield (lexp1, field_name, typ1) in

@ -422,7 +422,7 @@ let rec fsel_star_fld fsel1 fsel2 = match fsel1, fsel2 with
| [], fsel2 -> fsel2
| fsel1,[] -> fsel1
| (f1, se1):: fsel1', (f2, se2):: fsel2' ->
(match Ident.compare_fieldname f1 f2 with
(match Fieldname.compare f1 f2 with
| 0 -> (f1, sexp_star_fld se1 se2) :: fsel_star_fld fsel1' fsel2'
| n when n < 0 -> (f1, se1) :: fsel_star_fld fsel1' fsel2
| _ -> (f2, se2) :: fsel_star_fld fsel1 fsel2')
@ -465,7 +465,7 @@ let texp_star tenv texp1 texp2 =
| [], _ -> true
| _, [] -> false
| (f1, _, _):: ftal1', (f2, _, _):: ftal2' ->
begin match Ident.compare_fieldname f1 f2 with
begin match Fieldname.compare f1 f2 with
| n when n < 0 -> false
| 0 -> ftal_sub ftal1' ftal2'
| _ -> ftal_sub ftal1 ftal2' end in
@ -1084,7 +1084,7 @@ let exe_spec
let split = do_split () in
(* check if a missing_fld hpred is about a hidden field *)
let hpred_missing_hidden = function
| Sil.Hpointsto (_, Sil.Estruct ([(fld, _)], _), _) -> Ident.fieldname_is_hidden fld
| Sil.Hpointsto (_, Sil.Estruct ([(fld, _)], _), _) -> Fieldname.is_hidden fld
| _ -> false in
(* missing fields minus hidden fields *)
let missing_fld_nohidden =

@ -351,7 +351,7 @@ let tainted_params callee_pname =
let has_taint_annotation fieldname (struct_typ: Typ.Struct.t) =
let fld_has_taint_annot (fname, _, annot) =
Ident.equal_fieldname fieldname fname &&
Fieldname.equal fieldname fname &&
(Annotations.ia_is_privacy_source annot || Annotations.ia_is_integrity_source annot) in
List.exists ~f:fld_has_taint_annot struct_typ.fields ||
List.exists ~f:fld_has_taint_annot struct_typ.statics

@ -21,7 +21,7 @@ val accepts_sensitive_params :
val tainted_params : Typ.Procname.t -> (int * PredSymb.taint_kind) list
(** returns the taint_kind of [fieldname] if it has a taint source annotation *)
val has_taint_annotation : Ident.fieldname -> Typ.Struct.t -> bool
val has_taint_annotation : Fieldname.t -> Typ.Struct.t -> bool
val add_tainting_attribute : Tenv.t -> PredSymb.t -> Pvar.t -> Prop.normal Prop.t -> Prop.normal Prop.t

@ -24,7 +24,7 @@ struct
type t =
| Var of Var.t
| Allocsite of Allocsite.t
| Field of t * Ident.fieldname
| Field of t * Fieldname.t
[@@deriving compare]
let rec pp fmt = function
@ -35,7 +35,7 @@ struct
F.fprintf fmt "%s" (String.sub s 1 (String.length s - 1))
else F.fprintf fmt "%s" s
| Allocsite a -> Allocsite.pp fmt a
| Field (l, f) -> F.fprintf fmt "%a.%a" pp l Ident.pp_fieldname f
| Field (l, f) -> F.fprintf fmt "%a.%a" pp l Fieldname.pp f
let is_var = function Var _ -> true | _ -> false
let is_pvar_in_reg v =
Var.pp F.str_formatter v;

@ -38,7 +38,7 @@ let strip_container_write str =
let is_container_write_sink sink =
let _, access_list = fst (ThreadSafetyDomain.TraceElem.kind sink) in
match List.rev access_list with
| FieldAccess (fn) :: _ -> is_container_write_str (Ident.fieldname_to_string fn)
| FieldAccess (fn) :: _ -> is_container_write_str (Fieldname.to_string fn)
| _ -> false
module TransferFunctions (CFG : ProcCfg.S) = struct
@ -361,7 +361,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
(* create a dummy write that represents mutating the contents of the container *)
let open Domain in
let dummy_fieldname =
Ident.create_fieldname
Fieldname.create
(Mangled.from_string
(container_write_string ^ (Typ.Procname.get_method callee_pname))) 0 in
let dummy_access_exp = Exp.Lfield (receiver_exp, dummy_fieldname, receiver_typ) in

@ -26,7 +26,7 @@ let compare_base_untyped (base_var1, _) (base_var2, _) =
type access =
| ArrayAccess of Typ.t
| FieldAccess of Ident.fieldname
| FieldAccess of Fieldname.t
[@@deriving compare]
let equal_access = [%compare.equal : access]
@ -38,7 +38,7 @@ let pp_base fmt (pvar, _) =
Var.pp fmt pvar
let pp_access fmt = function
| FieldAccess field_name -> Ident.pp_fieldname fmt field_name
| FieldAccess field_name -> Fieldname.pp fmt field_name
| ArrayAccess _ -> F.fprintf fmt "[_]"
let pp_access_list fmt accesses =

@ -15,7 +15,7 @@ type base = Var.t * Typ.t [@@deriving compare]
type access =
| ArrayAccess of Typ.t (* array element type. index is unknown *)
| FieldAccess of Ident.fieldname (* field name *)
| FieldAccess of Fieldname.t (* field name *)
[@@deriving compare]
module Raw : sig

@ -111,7 +111,7 @@ let pname_has_return_annot pname ~attrs_of_pname predicate =
let field_has_annot fieldname (struct_typ : Typ.Struct.t) predicate =
let fld_has_taint_annot (fname, _, annot) =
Ident.equal_fieldname fieldname fname && predicate annot in
Fieldname.equal fieldname fname && predicate annot in
List.exists ~f:fld_has_taint_annot struct_typ.fields ||
List.exists ~f:fld_has_taint_annot struct_typ.statics

@ -108,7 +108,7 @@ val pdesc_return_annot_ends_with : Procdesc.t -> string -> bool
val ma_has_annotation_with : Annot.Method.t -> (Annot.t -> bool) -> bool
val field_has_annot : Ident.fieldname -> Typ.Struct.t -> (Annot.Item.t -> bool) -> bool
val field_has_annot : Fieldname.t -> Typ.Struct.t -> (Annot.Item.t -> bool) -> bool
(** return true if the given predicate evaluates to true on some annotation of [struct_typ] *)
val struct_typ_has_annot : Typ.Struct.t -> (Annot.Item.t -> bool) -> bool

@ -528,8 +528,8 @@ let callback_check_field_access { Callbacks.proc_desc; summary } =
do_exp is_read e
| Exp.Lvar _ -> ()
| Exp.Lfield (e, fn, _) ->
if not (Ident.java_fieldname_is_outer_instance fn) then
L.stdout "field %s %s@." (Ident.fieldname_to_string fn) (if is_read then "reading" else "writing");
if not (Fieldname.java_is_outer_instance fn) then
L.stdout "field %s %s@." (Fieldname.to_string fn) (if is_read then "reading" else "writing");
do_exp is_read e
| Exp.Lindex (e1, e2) ->
do_exp is_read e1;

@ -28,7 +28,7 @@ module ST : sig
Localise.t ->
Location.t ->
?advice: string option ->
?field_name: Ident.fieldname option ->
?field_name: Fieldname.t option ->
?origin_loc: Location.t option ->
?exception_kind: (string -> Localise.error_desc -> exn) ->
?always_report: bool ->

@ -31,7 +31,7 @@ let callback_fragment_retains_view_java
| _ -> false in
(* is [fldname] a View type declared by [class_typename]? *)
let is_declared_view_typ class_typename (fldname, fld_typ, _) =
let fld_classname = Typ.Name.Java.from_string (Ident.java_fieldname_get_class fldname) in
let fld_classname = Typ.Name.Java.from_string (Fieldname.java_get_class fldname) in
Typ.Name.equal fld_classname class_typename && fld_typ_is_view fld_typ in
if is_on_destroy_view then
begin
@ -45,7 +45,7 @@ let callback_fragment_retains_view_java
(* report if a field is declared by C, but not nulled out in C.onDestroyView *)
List.iter
~f:(fun (fname, fld_typ, _) ->
if not (Ident.FieldSet.mem fname fields_nullified) then
if not (Fieldname.Set.mem fname fields_nullified) then
report_error
(Tstruct class_typename) fname fld_typ summary proc_desc)
declared_view_fields

@ -129,13 +129,13 @@ let rec get_type_name = function
let get_field_type_name tenv
(typ: Typ.t)
(fieldname: Ident.fieldname): string option =
(fieldname: Fieldname.t): string option =
match typ with
| Tstruct name | Tptr (Tstruct name, _) -> (
match Tenv.lookup tenv name with
| Some { fields } -> (
match List.find
~f:(function | (fn, _, _) -> Ident.equal_fieldname fn fieldname)
~f:(function | (fn, _, _) -> Fieldname.equal fn fieldname)
fields with
| Some (_, ft, _) -> Some (get_type_name ft)
| None -> None
@ -226,7 +226,7 @@ let is_setter pname_java =
(** Returns the signature of a field access (class name, field name, field type name) *)
let get_java_field_access_signature = function
| Sil.Load (_, Exp.Lfield (_, fn, ft), bt, _) ->
Some (get_type_name bt, Ident.java_fieldname_get_field fn, get_type_name ft)
Some (get_type_name bt, Fieldname.java_get_field fn, get_type_name ft)
| _ -> None
(** Returns the formal signature (class name, method name,
@ -362,13 +362,13 @@ let get_fields_nullified procdesc =
let collect_nullified_flds (nullified_flds, this_ids) _ = function
| Sil.Store (Exp.Lfield (Exp.Var lhs, fld, _), _, rhs, _)
when Exp.is_null_literal rhs && Ident.IdentSet.mem lhs this_ids ->
(Ident.FieldSet.add fld nullified_flds, this_ids)
(Fieldname.Set.add fld nullified_flds, this_ids)
| Sil.Load (id, rhs, _, _) when Exp.is_this rhs ->
(nullified_flds, Ident.IdentSet.add id this_ids)
| _ -> (nullified_flds, this_ids) in
let (nullified_flds, _) =
Procdesc.fold_instrs
collect_nullified_flds (Ident.FieldSet.empty, Ident.IdentSet.empty) procdesc in
collect_nullified_flds (Fieldname.Set.empty, Ident.IdentSet.empty) procdesc in
nullified_flds
(** Checks if the exception is an unchecked exception *)

@ -108,7 +108,7 @@ val type_is_nested_in_direct_supertype : Tenv.t -> Typ.t -> Typ.Name.t -> bool
val type_is_object : Typ.t -> bool
(** return the set of instance fields that are assigned to a null literal in [procdesc] *)
val get_fields_nullified : Procdesc.t -> Ident.FieldSet.t
val get_fields_nullified : Procdesc.t -> Fieldname.Set.t
(** [is_exception tenv class_name] checks if class_name is of type java.lang.Exception *)
val is_exception : Tenv.t -> Typ.Name.t -> bool

@ -13,7 +13,7 @@ open! IStd
module L = Logging
type field_type = Ident.fieldname * Typ.t * (Annot.t * bool) list
type field_type = Fieldname.t * Typ.t * (Annot.t * bool) list
let rec get_fields_super_classes tenv super_class =
Logging.out_debug " ... Getting fields of superclass '%s'\n" (Typ.Name.to_string super_class);

@ -11,7 +11,7 @@ open! IStd
(** Utility module to retrieve fields of structs of classes *)
type field_type = Ident.fieldname * Typ.t * (Annot.t * bool) list
type field_type = Fieldname.t * Typ.t * (Annot.t * bool) list
val get_fields : CAst_utils.type_ptr_to_sil_type -> Tenv.t -> Clang_ast_t.decl list ->
field_type list

@ -49,7 +49,7 @@ let add_no_duplicates_fields field_tuple l =
match field_tuple, l with
| (field, typ, annot), ((old_field, old_typ, old_annot) as old_field_tuple :: rest) ->
let ret_list, ret_found = replace_field field_tuple rest found in
if Ident.equal_fieldname field old_field && Typ.equal typ old_typ then
if Fieldname.equal field old_field && Typ.equal typ old_typ then
let annotations = append_no_duplicates_annotations annot old_annot in
(field, typ, annotations) :: ret_list, true
else old_field_tuple :: ret_list, ret_found
@ -67,7 +67,7 @@ let rec append_no_duplicates_fields list1 list2 =
let sort_fields fields =
let compare (name1, _, _) (name2, _, _) =
Ident.compare_fieldname name1 name2 in
Fieldname.compare name1 name2 in
List.sort ~cmp:compare fields
@ -102,7 +102,7 @@ let replicate n el = List.map ~f:(fun _ -> el) (list_range 0 (n -1))
let mk_class_field_name field_qual_name =
let field_name = field_qual_name.Clang_ast_t.ni_name in
let class_name = CAst_utils.get_class_name_from_member field_qual_name in
Ident.create_fieldname (Mangled.mangled field_name class_name) 0
Fieldname.create (Mangled.mangled field_name class_name) 0
let is_cpp_translation translation_unit_context =
let lang = translation_unit_context.CFrontend_config.lang in

@ -16,16 +16,16 @@ type var_info = Clang_ast_t.decl_info * Clang_ast_t.qual_type * Clang_ast_t.var_
val string_from_list : string list -> string
val append_no_duplicates_fields : (Ident.fieldname * Typ.t * Annot.Item.t) list ->
(Ident.fieldname * Typ.t * Annot.Item.t) list ->
(Ident.fieldname * Typ.t * Annot.Item.t) list
val append_no_duplicates_fields : (Fieldname.t * Typ.t * Annot.Item.t) list ->
(Fieldname.t * Typ.t * Annot.Item.t) list ->
(Fieldname.t * Typ.t * Annot.Item.t) list
val append_no_duplicates_csu :
Typ.Name.t list -> Typ.Name.t list -> Typ.Name.t list
val sort_fields :
(Ident.fieldname * Typ.t * Annot.Item.t) list ->
(Ident.fieldname * Typ.t * Annot.Item.t) list
(Fieldname.t * Typ.t * Annot.Item.t) list ->
(Fieldname.t * Typ.t * Annot.Item.t) list
val sort_fields_tenv : Tenv.t -> unit
@ -43,7 +43,7 @@ val list_range: int -> int -> int list
val replicate: int -> 'a -> 'a list
val mk_class_field_name : Clang_ast_t.named_decl_info -> Ident.fieldname
val mk_class_field_name : Clang_ast_t.named_decl_info -> Fieldname.t
val get_var_name_mangled : Clang_ast_t.named_decl_info -> Clang_ast_t.var_decl_info ->
(string * Mangled.t)

@ -115,7 +115,7 @@ struct
let fields = List.map ~f:mk_field_from_captured_var captured_vars in
Logging.out_debug "Block %s field:\n" block_name;
List.iter ~f:(fun (fn, _, _) ->
Logging.out_debug "-----> field: '%s'\n" (Ident.fieldname_to_string fn)) fields;
Logging.out_debug "-----> field: '%s'\n" (Fieldname.to_string fn)) fields;
let block_typename = Typ.Name.Objc.from_string block_name in
ignore (Tenv.mk_struct tenv ~fields block_typename);
let block_type = Typ.Tstruct block_typename in

@ -86,7 +86,7 @@ let add_class_to_tenv type_ptr_to_sil_type tenv decl_info name_info decl_list oc
ocidi.Clang_ast_t.otdi_protocols in
let fields_sc = CField_decl.fields_superclass tenv ocidi in
List.iter ~f:(fun (fn, ft, _) ->
Logging.out_debug "----->SuperClass field: '%s' " (Ident.fieldname_to_string fn);
Logging.out_debug "----->SuperClass field: '%s' " (Fieldname.to_string fn);
Logging.out_debug "type: '%s'\n" (Typ.to_string ft)) fields_sc;
(*In case we found categories, or partial definition of this class earlier and they are already in the tenv *)
let fields, (supers : Typ.Name.t list) =
@ -102,7 +102,7 @@ let add_class_to_tenv type_ptr_to_sil_type tenv decl_info name_info decl_list oc
let all_fields = CGeneral_utils.append_no_duplicates_fields modelled_fields fields in
Logging.out_debug "Class %s field:\n" class_name;
List.iter ~f:(fun (fn, _, _) ->
Logging.out_debug "-----> field: '%s'\n" (Ident.fieldname_to_string fn)) all_fields;
Logging.out_debug "-----> field: '%s'\n" (Fieldname.to_string fn)) all_fields;
ignore(
Tenv.mk_struct tenv
~fields: all_fields ~supers ~methods:[] ~annots:Annot.Class.objc interface_name );

@ -189,13 +189,13 @@ let check_field_assignment tenv
not (TypeAnnotation.get_value AnnotatedSignature.Nullable ta_lhs) &&
TypeAnnotation.get_value AnnotatedSignature.Nullable ta_rhs &&
PatternMatch.type_is_class t_lhs &&
not (Ident.java_fieldname_is_outer_instance fname) &&
not (Fieldname.java_is_outer_instance fname) &&
not (field_is_field_injector_readwrite ()) in
let should_report_absent =
Config.eradicate_optional_present &&
TypeAnnotation.get_value AnnotatedSignature.Present ta_lhs &&
not (TypeAnnotation.get_value AnnotatedSignature.Present ta_rhs) &&
not (Ident.java_fieldname_is_outer_instance fname) in
not (Fieldname.java_is_outer_instance fname) in
let should_report_mutable =
let field_is_mutable () = match t_ia_opt with
| Some (_, ia) -> Annotations.ia_is_mutable ia
@ -261,7 +261,7 @@ let check_constructor_initialization tenv
List.exists
~f:(function pname, typestate ->
let pvar = Pvar.mk
(Mangled.from_string (Ident.fieldname_to_string fn))
(Mangled.from_string (Fieldname.to_string fn))
pname in
filter_range_opt (TypeState.lookup_pvar pvar typestate))
list in
@ -288,12 +288,12 @@ let check_constructor_initialization tenv
let should_check_field_initialization =
let in_current_class =
let fld_cname = Ident.java_fieldname_get_class fn in
let fld_cname = Fieldname.java_get_class fn in
String.equal (Typ.Name.name name) fld_cname in
not injector_readonly_annotated &&
PatternMatch.type_is_class ft &&
in_current_class &&
not (Ident.java_fieldname_is_outer_instance fn) in
not (Fieldname.java_is_outer_instance fn) in
if should_check_field_initialization then (
if Models.Inference.enabled then Models.Inference.field_add_nullable_annotation fn;

@ -25,7 +25,7 @@ module Inference = struct
let get_dir () = Filename.concat Config.results_dir "eradicate"
let field_get_dir_fname fn =
let fname = Ident.fieldname_to_string fn in
let fname = Fieldname.to_string fn in
(get_dir (), fname)
let field_is_marked fn =

@ -93,7 +93,7 @@ module ComplexExpressions = struct
dexp_to_string de1 ^ "[" ^ dexp_to_string de2 ^ "]"
| DExp.Darrow (de, f)
| DExp.Ddot (de, f) ->
dexp_to_string de ^ "." ^ Ident.fieldname_to_string f
dexp_to_string de ^ "." ^ Fieldname.to_string f
| DExp.Dbinop (op, de1, de2) ->
"(" ^ dexp_to_string de1 ^ (Binop.str Pp.text op) ^ dexp_to_string de2 ^ ")"
| DExp.Dconst (Const.Cfun pn) ->
@ -221,7 +221,7 @@ let rec typecheck_expr
match EradicateChecks.explain_expr tenv node index_exp with
| Some s -> s
| None -> "?" in
let fname = Ident.create_fieldname
let fname = Fieldname.create
(Mangled.from_string index)
0 in
if checks.eradicate then
@ -370,13 +370,13 @@ let typecheck_instr
let res = match exp' with
| Exp.Lvar pv when is_parameter_field pv || is_static_field pv ->
let fld_name = pvar_to_str pv ^ Ident.fieldname_to_string fn in
let fld_name = pvar_to_str pv ^ Fieldname.to_string fn in
let pvar = Pvar.mk (Mangled.from_string fld_name) curr_pname in
let typestate' = update_typestate_fld pvar inner_origin fn typ in
(Exp.Lvar pvar, typestate')
| Exp.Lfield (_exp', fn', _) when Ident.java_fieldname_is_outer_instance fn' ->
| Exp.Lfield (_exp', fn', _) when Fieldname.java_is_outer_instance fn' ->
(* handle double dereference when accessing a field from an outer class *)
let fld_name = Ident.fieldname_to_string fn' ^ "_" ^ Ident.fieldname_to_string fn in
let fld_name = Fieldname.to_string fn' ^ "_" ^ Fieldname.to_string fn in
let pvar = Pvar.mk (Mangled.from_string fld_name) curr_pname in
let typestate' = update_typestate_fld pvar inner_origin fn typ in
(Exp.Lvar pvar, typestate')
@ -560,7 +560,7 @@ let typecheck_instr
node
instr_ref
array_exp
(Ident.create_fieldname (Mangled.from_string "length") 0)
(Fieldname.create (Mangled.from_string "length") 0)
ta
loc
false;

@ -70,11 +70,11 @@ type err_instance =
| Condition_redundant of (bool * (string option) * bool)
| Inconsistent_subclass_return_annotation of Typ.Procname.t * Typ.Procname.t
| Inconsistent_subclass_parameter_annotation of string * int * Typ.Procname.t * Typ.Procname.t
| Field_not_initialized of Ident.fieldname * Typ.Procname.t
| Field_not_mutable of Ident.fieldname * origin_descr
| Field_annotation_inconsistent of AnnotatedSignature.annotation * Ident.fieldname * origin_descr
| Field_over_annotated of Ident.fieldname * Typ.Procname.t
| Null_field_access of string option * Ident.fieldname * origin_descr * bool
| Field_not_initialized of Fieldname.t * Typ.Procname.t
| Field_not_mutable of Fieldname.t * origin_descr
| Field_annotation_inconsistent of AnnotatedSignature.annotation * Fieldname.t * origin_descr
| Field_over_annotated of Fieldname.t * Typ.Procname.t
| Null_field_access of string option * Fieldname.t * origin_descr * bool
| Call_receiver_annotation_inconsistent
of AnnotatedSignature.annotation * string option * Typ.Procname.t * origin_descr
| Parameter_annotation_inconsistent of parameter_not_nullable
@ -94,15 +94,15 @@ module H = Hashtbl.Make(struct
| Condition_redundant (b, so, nn) ->
Hashtbl.hash (1, b, string_opt_hash so, nn)
| Field_not_initialized (fn, pn) ->
Hashtbl.hash (2, string_hash ((Ident.fieldname_to_string fn) ^ (Typ.Procname.to_string pn)))
Hashtbl.hash (2, string_hash ((Fieldname.to_string fn) ^ (Typ.Procname.to_string pn)))
| Field_not_mutable (fn, _) ->
Hashtbl.hash (3, string_hash (Ident.fieldname_to_string fn))
Hashtbl.hash (3, string_hash (Fieldname.to_string fn))
| Field_annotation_inconsistent (ann, fn, _) ->
Hashtbl.hash (4, ann, string_hash (Ident.fieldname_to_string fn))
Hashtbl.hash (4, ann, string_hash (Fieldname.to_string fn))
| Field_over_annotated (fn, pn) ->
Hashtbl.hash (5, string_hash ((Ident.fieldname_to_string fn) ^ (Typ.Procname.to_string pn)))
Hashtbl.hash (5, string_hash ((Fieldname.to_string fn) ^ (Typ.Procname.to_string pn)))
| Null_field_access (so, fn, _, _) ->
Hashtbl.hash (6, string_opt_hash so, string_hash (Ident.fieldname_to_string fn))
Hashtbl.hash (6, string_opt_hash so, string_hash (Fieldname.to_string fn))
| Call_receiver_annotation_inconsistent (ann, so, pn, _) ->
Hashtbl.hash (7, ann, string_opt_hash so, Typ.Procname.hash_pname pn)
| Parameter_annotation_inconsistent (ann, s, n, pn, _, _) ->
@ -231,7 +231,7 @@ type st_report_error =
Localise.t ->
Location.t ->
?advice: string option ->
?field_name: Ident.fieldname option ->
?field_name: Fieldname.t option ->
?origin_loc: Location.t option ->
?exception_kind: (string -> Localise.error_desc -> exn) ->
?always_report: bool ->
@ -282,7 +282,7 @@ let report_error_now tenv
Localise.eradicate_field_not_initialized,
Format.asprintf
"Field %a is not initialized in %s and is not declared %a"
MF.pp_monospaced (Ident.fieldname_to_simplified_string fn)
MF.pp_monospaced (Fieldname.to_simplified_string fn)
constructor_name
MF.pp_monospaced "@Nullable",
None,
@ -293,7 +293,7 @@ let report_error_now tenv
Localise.eradicate_field_not_mutable,
Format.asprintf
"Field %a is modified but is not declared %a. %s"
MF.pp_monospaced (Ident.fieldname_to_simplified_string fn)
MF.pp_monospaced (Fieldname.to_simplified_string fn)
MF.pp_monospaced "@Mutable"
origin_description,
None,
@ -305,14 +305,14 @@ let report_error_now tenv
Localise.eradicate_field_not_nullable,
Format.asprintf
"Field %a can be null but is not declared %a. %s"
MF.pp_monospaced (Ident.fieldname_to_simplified_string fn)
MF.pp_monospaced (Fieldname.to_simplified_string fn)
MF.pp_monospaced "@Nullable"
origin_description
| AnnotatedSignature.Present ->
Localise.eradicate_field_value_absent,
Format.asprintf
"Field %a is assigned a possibly absent value but is declared %a. %s"
MF.pp_monospaced (Ident.fieldname_to_simplified_string fn)
MF.pp_monospaced (Fieldname.to_simplified_string fn)
MF.pp_monospaced "@Present"
origin_description in
true,
@ -335,7 +335,7 @@ let report_error_now tenv
Localise.eradicate_field_over_annotated,
Format.asprintf
"Field %a is always initialized in %s but is declared %a"
MF.pp_monospaced (Ident.fieldname_to_simplified_string fn)
MF.pp_monospaced (Fieldname.to_simplified_string fn)
constructor_name
MF.pp_monospaced "@Nullable",
None,
@ -349,7 +349,7 @@ let report_error_now tenv
"Object %a could be null when accessing %s %a. %s"
MF.pp_monospaced (Option.value s_opt ~default:"")
at_index
MF.pp_monospaced (Ident.fieldname_to_simplified_string fn)
MF.pp_monospaced (Fieldname.to_simplified_string fn)
origin_description,
None,
None,

@ -52,11 +52,11 @@ type err_instance =
| Condition_redundant of (bool * (string option) * bool)
| Inconsistent_subclass_return_annotation of Typ.Procname.t * Typ.Procname.t
| Inconsistent_subclass_parameter_annotation of string * int * Typ.Procname.t * Typ.Procname.t
| Field_not_initialized of Ident.fieldname * Typ.Procname.t
| Field_not_mutable of Ident.fieldname * origin_descr
| Field_annotation_inconsistent of AnnotatedSignature.annotation * Ident.fieldname * origin_descr
| Field_over_annotated of Ident.fieldname * Typ.Procname.t
| Null_field_access of string option * Ident.fieldname * origin_descr * bool
| Field_not_initialized of Fieldname.t * Typ.Procname.t
| Field_not_mutable of Fieldname.t * origin_descr
| Field_annotation_inconsistent of AnnotatedSignature.annotation * Fieldname.t * origin_descr
| Field_over_annotated of Fieldname.t * Typ.Procname.t
| Null_field_access of string option * Fieldname.t * origin_descr * bool
| Call_receiver_annotation_inconsistent
of AnnotatedSignature.annotation * string option * Typ.Procname.t * origin_descr
| Parameter_annotation_inconsistent of parameter_not_nullable
@ -72,7 +72,7 @@ type st_report_error =
Localise.t ->
Location.t ->
?advice: string option ->
?field_name: Ident.fieldname option ->
?field_name: Fieldname.t option ->
?origin_loc: Location.t option ->
?exception_kind: (string -> Localise.error_desc -> exn) ->
?always_report: bool ->

@ -26,7 +26,7 @@ type proc_origin =
type t =
| Const of Location.t
| Field of t * Ident.fieldname * Location.t
| Field of t * Fieldname.t * Location.t
| Formal of Mangled.t
| Proc of proc_origin
| New
@ -40,7 +40,7 @@ let rec to_string = function
| Const _ ->
"Const"
| Field (o, fn, _) ->
"Field " ^ Ident.fieldname_to_simplified_string fn ^ (" (inner: " ^ to_string o ^ ")")
"Field " ^ Fieldname.to_simplified_string fn ^ (" (inner: " ^ to_string o ^ ")")
| Formal s ->
"Formal " ^ Mangled.to_string s
| Proc po ->
@ -61,7 +61,7 @@ let get_description tenv origin =
| Const loc ->
Some ("null constant" ^ atline loc, Some loc, None)
| Field (_, fn, loc) ->
Some ("field " ^ Ident.fieldname_to_simplified_string fn ^ atline loc, Some loc, None)
Some ("field " ^ Fieldname.to_simplified_string fn ^ atline loc, Some loc, None)
| Formal s ->
Some ("method parameter " ^ Mangled.to_string s, None, None)
| Proc po ->

@ -20,7 +20,7 @@ type proc_origin =
type t =
| Const of Location.t (** A constant in the source *)
| Field of t * Ident.fieldname * Location.t (** A field access *)
| Field of t * Fieldname.t * Location.t (** A field access *)
| Formal of Mangled.t (** A formal parameter *)
| Proc of proc_origin (** A procedure call *)
| New (** A new object creation *)

@ -96,7 +96,7 @@ let get_undefined_method_call ovt =
let retrieve_fieldname fieldname =
try
let subs = Str.split (Str.regexp (Str.quote ".")) (Ident.fieldname_to_string fieldname) in
let subs = Str.split (Str.regexp (Str.quote ".")) (Fieldname.to_string fieldname) in
if Int.equal (List.length subs) 0 then
assert false
else

@ -204,16 +204,16 @@ let translate_method_name m =
get_method_procname cn ms (get_method_kind m)
let create_fieldname cn fs =
let fieldname_create cn fs =
let fieldname cn fs =
let fieldname = (JBasics.fs_name fs) in
let classname = (JBasics.cn_name cn) in
Mangled.from_string (classname^"."^fieldname) in
Ident.create_fieldname (fieldname cn fs) 0
Fieldname.create (fieldname cn fs) 0
let create_sil_class_field cn cf =
let fs = cf.Javalib.cf_signature in
let field_name = create_fieldname cn fs
let field_name = fieldname_create cn fs
and field_type = get_named_type (JBasics.fs_type fs)
and annotation =
let real_annotations = JAnnotation.translate_item cf.Javalib.cf_annotations in
@ -237,7 +237,7 @@ let collect_class_field cn cf (statics, nonstatics) =
let collect_interface_field cn inf l =
let fs = inf.Javalib.if_signature in
let field_type = get_named_type (JBasics.fs_type fs) in
let field_name = create_fieldname cn fs in
let field_name = fieldname_create cn fs in
let annotation = JAnnotation.translate_item inf.Javalib.if_annotations in
(field_name, field_type, annotation) :: l
@ -246,12 +246,12 @@ let collect_models_class_fields classpath_field_map cn cf fields =
let static, nonstatic = fields in
let field_name, field_type, annotation = create_sil_class_field cn cf in
try
let classpath_ft = Ident.FieldMap.find field_name classpath_field_map in
let classpath_ft = Fieldname.Map.find field_name classpath_field_map in
if Typ.equal classpath_ft field_type then fields
else
(* TODO (#6711750): fix type equality for arrays before failing here *)
let () = Logging.stderr "Found inconsistent types for %s\n\tclasspath: %a\n\tmodels: %a\n@."
(Ident.fieldname_to_string field_name)
(Fieldname.to_string field_name)
(Typ.pp_full Pp.text) classpath_ft
(Typ.pp_full Pp.text) field_type in fields
with Not_found ->
@ -266,8 +266,8 @@ let add_model_fields program classpath_fields cn =
let classpath_field_map =
let collect_fields map =
List.fold
~f:(fun map (fn, ft, _) -> Ident.FieldMap.add fn ft map) ~init:map in
collect_fields (collect_fields Ident.FieldMap.empty statics) nonstatics in
~f:(fun map (fn, ft, _) -> Fieldname.Map.add fn ft map) ~init:map in
collect_fields (collect_fields Fieldname.Map.empty statics) nonstatics in
try
match JBasics.ClassMap.find cn (JClasspath.get_models program) with
| Javalib.JClass _ as jclass ->
@ -349,7 +349,7 @@ let get_class_type program tenv cn =
(** return true if [field_name] is the autogenerated C.$assertionsDisabled field for class C *)
let is_autogenerated_assert_field field_name =
String.equal (Ident.java_fieldname_get_field field_name) "$assertionsDisabled"
String.equal (Fieldname.java_get_field field_name) "$assertionsDisabled"
let is_closeable program tenv typ =
let closeable_cn = JBasics.make_cn "java.io.Closeable" in

@ -20,7 +20,7 @@ val get_named_type : JBasics.value_type -> Typ.t
val typename_of_classname : JBasics.class_name -> Typ.Name.t
(** returns a name for a field based on a class name and a field name *)
val create_fieldname : JBasics.class_name -> JBasics.field_signature -> Ident.fieldname
val fieldname_create : JBasics.class_name -> JBasics.field_signature -> Fieldname.t
val get_method_kind : JCode.jcode Javalib.jmethod -> Typ.Procname.method_kind
@ -42,7 +42,7 @@ val get_class_type_no_pointer: JClasspath.program -> Tenv.t -> JBasics.class_nam
val get_class_type : JClasspath.program -> Tenv.t -> JBasics.class_name -> Typ.t
(** return true if [field_name] is the autogenerated C.$assertionsDisabled field for class C *)
val is_autogenerated_assert_field : Ident.fieldname -> bool
val is_autogenerated_assert_field : Fieldname.t -> bool
(** [is_closeable program tenv typ] check if typ is an implemtation of the Closeable interface *)
val is_closeable : JClasspath.program -> Tenv.t -> Typ.t -> bool

@ -16,7 +16,7 @@ let make_base ?(typ=Typ.Tvoid) base_str =
AccessPath.base_of_pvar (make_var base_str) typ
let make_fieldname fld_str =
Ident.create_fieldname (Mangled.from_string fld_str) 0
Fieldname.create (Mangled.from_string fld_str) 0
let make_field_access access_str =
AccessPath.FieldAccess (make_fieldname access_str)

@ -9,7 +9,7 @@
val make_var : string -> Pvar.t
val make_fieldname : string -> Ident.fieldname
val make_fieldname : string -> Fieldname.t
val make_base : ?typ:Typ.t -> string -> AccessPath.base

Loading…
Cancel
Save