Skip to content

Commit

Permalink
[pulse][rec] ignore self argument in Hack
Browse files Browse the repository at this point in the history
Summary: Hacky but serviceable.

Reviewed By: geralt-encore

Differential Revision:
D66876195

Privacy Context Container: L1208441

fbshipit-source-id: 99c211ab3f64cec76540f66578f9cb151d08b577
  • Loading branch information
jvillard authored and facebook-github-bot committed Dec 9, 2024
1 parent 6ed37e0 commit 77bea30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions infer/src/pulse/PulseAbductiveDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1670,15 +1670,18 @@ let mk_initial tenv (proc_attrs : ProcAttributes.t) =
let are_same_values_as_pre_formals proc_desc values astate =
List.for_all2 (Procdesc.get_formals proc_desc) values ~f:(fun (mangled_name, _, _) v ->
let formal = Pvar.mk mangled_name (Procdesc.get_proc_name proc_desc) in
let formal_addr =
SafeStack.find_opt `Pre (Var.of_pvar formal) astate |> Option.value_exn |> ValueOrigin.value
in
let formal_v =
SafeMemory.find_edge_opt `Pre formal_addr Dereference astate
|> Option.value_exn |> fst |> downcast
in
AbstractValue.equal formal_v v )
if Language.curr_language_is Hack && Mangled.is_self mangled_name then true
else
let formal = Pvar.mk mangled_name (Procdesc.get_proc_name proc_desc) in
let formal_addr =
SafeStack.find_opt `Pre (Var.of_pvar formal) astate
|> Option.value_exn |> ValueOrigin.value
in
let formal_v =
SafeMemory.find_edge_opt `Pre formal_addr Dereference astate
|> Option.value_exn |> fst |> downcast
in
AbstractValue.equal formal_v v )
|> function List.Or_unequal_lengths.Ok b -> b | List.Or_unequal_lengths.Unequal_lengths -> false
Expand Down
2 changes: 1 addition & 1 deletion infer/tests/codetoanalyze/hack/pulse/issues.exp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ recursion.hack, Recursion::AA$static.something, 1, INFINITE_RECURSION, no_bucket
recursion.hack, Recursion::AA$static.something_else, 1, INFINITE_RECURSION, no_bucket, WARNING, [`Recursion::AA$static.something_else` calls `Recursion::BB$static.something`,`Recursion::BB$static.something` calls `Recursion::BB$static.something_else`,`Recursion::BB$static.something_else` calls `Recursion::AA$static.something`,`Recursion::AA$static.something` makes a recursive call to `Recursion::AA$static.something_else` with the same argument values]
recursion.hack, Recursion::BB$static.something, 1, INFINITE_RECURSION, no_bucket, WARNING, [`Recursion::BB$static.something` calls `Recursion::BB$static.something_else`,`Recursion::BB$static.something_else` calls `Recursion::AA$static.something`,`Recursion::AA$static.something` calls `Recursion::AA$static.something_else`,`Recursion::AA$static.something_else` makes a recursive call to `Recursion::BB$static.something` with the same argument values]
recursion.hack, Recursion::BB$static.something_else, 1, INFINITE_RECURSION, no_bucket, WARNING, [`Recursion::BB$static.something_else` calls `Recursion::AA$static.something`,`Recursion::AA$static.something` calls `Recursion::AA$static.something_else`,`Recursion::AA$static.something_else` calls `Recursion::BB$static.something`,`Recursion::BB$static.something` makes a recursive call to `Recursion::BB$static.something_else` with the same argument values]
recursion.hack, Recursion::InfiniteRecursionInTrait.infinite_same_args_bad, 1, MUTUAL_RECURSION_CYCLE, no_bucket, WARNING, [`Recursion::InfiniteRecursionInTrait.infinite_same_args_bad` makes a recursive call to `Recursion::InfiniteRecursionInTrait.infinite_same_args_bad`]
recursion.hack, Recursion::InfiniteRecursionInTrait.infinite_same_args_bad, 1, INFINITE_RECURSION, no_bucket, WARNING, [`Recursion::InfiniteRecursionInTrait.infinite_same_args_bad` makes a recursive call to `Recursion::InfiniteRecursionInTrait.infinite_same_args_bad` with the same argument values]
return_type_matcher.hack, ReturnTypeMatcher::Flows$static.source1TaintFlowBad, 2, TAINT_ERROR, no_bucket, ERROR, [source of the taint here: value returned from `ReturnTypeMatcher::Source1$static.getTainted` with kind `ReturnTypeMatcher`,flows to this sink: value passed as argument `#0` to `ReturnTypeMatcher::Sink$static.process` with kind `ReturnTypeMatcher`], source: ReturnTypeMatcher::Source1$static.getTainted, sink: ReturnTypeMatcher::Sink$static.process, tainted expression: $source
return_type_matcher.hack, ReturnTypeMatcher::Flows$static.source2TaintFlowBad, 2, TAINT_ERROR, no_bucket, ERROR, [source of the taint here: value returned from `ReturnTypeMatcher::Source2$static.getTainted` with kind `ReturnTypeMatcher`,flows to this sink: value passed as argument `#0` to `ReturnTypeMatcher::Sink$static.process` with kind `ReturnTypeMatcher`], source: ReturnTypeMatcher::Source2$static.getTainted, sink: ReturnTypeMatcher::Sink$static.process, tainted expression: $source
sanitizers.hack, Sanitizers::Flows$static.taintedNotSanitizedBad, 2, TAINT_ERROR, no_bucket, ERROR, [source of the taint here: value returned from `Sanitizers::Source.getTainted` with kind `Sanitizers`,flows to this sink: value passed as argument `#0` to `Sanitizers::Sink$static.process` with kind `Sanitizers`], source: Sanitizers::Source.getTainted, sink: Sanitizers::Sink$static.process, tainted expression: $t
Expand Down

0 comments on commit 77bea30

Please sign in to comment.