[threadsafety] Relax javaism of may_alias

Summary:
ThreadSafety.may_alias crashed on C++ code because it assumed Java
field names.

Reviewed By: sblackshear

Differential Revision: D5147284

fbshipit-source-id: d10841f
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent c46d698ecb
commit b4b45236fd

@ -99,6 +99,16 @@ let java_get_field fn => {
};
/** Equality for field names ignoring the struct or class which contains the field. */
let equal_modulo_parent x y =>
switch (x, y) {
| (Hidden, Hidden) => true
| (Clang a, Clang b) => Int.equal 0 (compare_clang_field_info a b)
| (Java _, Java _) => String.equal (java_get_field x) (java_get_field y)
| _ => false
};
/** 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;

@ -17,6 +17,10 @@ type t [@@deriving compare];
let equal: t => t => bool;
/** Equality for field names ignoring the struct or class which contains the field. */
let equal_modulo_parent: t => t => bool;
/** Set for fieldnames */
module Set: Caml.Set.S with type elt = t;

@ -1219,8 +1219,7 @@ let may_alias p1 p2 =
match List.last_exn (snd p1), List.last_exn (snd p2) with
| FieldAccess _, ArrayAccess _ | ArrayAccess _, FieldAccess _ -> false
(* fields in Infer contain class name *)
| FieldAccess f1, FieldAccess f2 ->
String.equal (Fieldname.java_get_field f1) (Fieldname.java_get_field f2)
| FieldAccess f1, FieldAccess f2 -> Fieldname.equal_modulo_parent f1 f2
| ArrayAccess _, ArrayAccess _ -> true (*FIXME*)
(* take a results table and quotient it by the may_alias relation *)

Loading…
Cancel
Save