[pulse] Fix operator= case with temporaries

Summary: In the `operator=` case that assigns from a temporary, we want to assign an object of a temporary not it's address (as a comment already says)

Reviewed By: jvillard

Differential Revision: D13518496

fbshipit-source-id: 72bd23623
master
Daiva Naudziuniene 6 years ago committed by Facebook Github Bot
parent 1827b42f68
commit 2a139a2220

@ -93,10 +93,10 @@ module PulseTransferFunctions (CFG : ProcCfg.S) = struct
when Typ.Procname.ObjC_Cpp.is_operator_equal callee_pname -> (
match actuals with
(* We want to assign *lhs to *rhs when rhs is materialized temporary created in constructor *)
| [AccessExpression lhs; (HilExp.AccessExpression (AddressOf (Base rhs_base)) as rhs_exp)]
| [AccessExpression lhs; HilExp.AccessExpression (AddressOf (Base rhs_base as rhs_exp))]
when Var.is_cpp_temporary (fst rhs_base) ->
let lhs_deref = HilExp.AccessExpression.dereference lhs in
exec_assign summary lhs_deref rhs_exp call_loc astate
exec_assign summary lhs_deref (HilExp.AccessExpression rhs_exp) call_loc astate
(* copy assignment *)
| [AccessExpression lhs; HilExp.AccessExpression rhs] ->
let lhs_deref = HilExp.AccessExpression.dereference lhs in

@ -63,7 +63,7 @@ module Cplusplus = struct
>>= fun astate ->
( match actuals with
| AccessExpression lambda :: _ ->
PulseDomain.read location HilExp.AccessExpression.(dereference (dereference lambda)) astate
PulseDomain.read location HilExp.AccessExpression.(dereference lambda) astate
>>= fun (astate, address) ->
PulseDomain.Closures.check_captured_addresses location lambda address astate
| _ ->

Loading…
Cancel
Save