From 2a139a22201011706a0859057afe904da3209082 Mon Sep 17 00:00:00 2001 From: Daiva Naudziuniene Date: Wed, 19 Dec 2018 12:45:43 -0800 Subject: [PATCH] [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 --- infer/src/checkers/Pulse.ml | 4 ++-- infer/src/checkers/PulseModels.ml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/infer/src/checkers/Pulse.ml b/infer/src/checkers/Pulse.ml index 149c6bdf4..0359d6492 100644 --- a/infer/src/checkers/Pulse.ml +++ b/infer/src/checkers/Pulse.ml @@ -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 diff --git a/infer/src/checkers/PulseModels.ml b/infer/src/checkers/PulseModels.ml index 23a2a9b6c..770d9208c 100644 --- a/infer/src/checkers/PulseModels.ml +++ b/infer/src/checkers/PulseModels.ml @@ -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 | _ ->