Lazy dinamic dispatch: add missing case where the right hand side is a idenfier

Summary:
The case where the right hand side of the `Letderef` expression is an identifier was missing. With this diff, the following example is now working as expected:

  class A {
    public Object foo() {
      return new Object();
    }
  }

  class B extends A {
    public Object foo() {
      return null;
     }
   }

  public class Test {

    static Object bar(A a) {
      return a.foo();
     }

    static void shoulReport() {
      B b = new B();
      bar(b).toString();
    }
  }

using the command:

  INFER_LAZY_DYNAMIC_DISPATCH=1 infer -- javac Test.java

Reviewed By: sblackshear

Differential Revision: D3238986

fb-gh-sync-id: d6059fb
fbshipit-source-id: d6059fb
master
Jeremy Dubreil 9 years ago committed by Facebook Github Bot 7
parent e96b94204c
commit b3baf72df8

@ -692,6 +692,13 @@ module Node = struct
(pvar_name, origin_typ) in
subst_map := Ident.IdentMap.add id specialized_typ !subst_map;
Sil.Letderef (id, convert_exp origin_exp, specialized_typ, loc) :: instrs
| Sil.Letderef (id, (Sil.Var origin_id as origin_exp), origin_typ, loc) ->
let updated_typ =
match Ident.IdentMap.find origin_id !subst_map with
| Sil.Tptr (typ, _) -> typ
| _ -> failwith "Expecting a pointer type"
| exception Not_found -> origin_typ in
Sil.Letderef (id, convert_exp origin_exp, updated_typ, loc) :: instrs
| Sil.Letderef (id, origin_exp, origin_typ, loc) ->
Sil.Letderef (id, convert_exp origin_exp, origin_typ, loc) :: instrs
| Sil.Set (assignee_exp, origin_typ, origin_exp, loc) ->
@ -733,8 +740,8 @@ module Node = struct
let loc = get_loc node
and kind = convert_node_kind (get_kind node)
and instrs =
IList.fold_left convert_instr [] (get_instrs node) in
create cfg loc kind (IList.rev instrs) resolved_proc_desc (get_temps node)
IList.fold_left convert_instr [] (get_instrs node) |> IList.rev in
create cfg loc kind instrs resolved_proc_desc (get_temps node)
and loop callee_nodes =
match callee_nodes with
| [] -> []

Loading…
Cancel
Save