Skip to content

Commit

Permalink
[pulse] Simple model for thrift field ref accesses
Browse files Browse the repository at this point in the history
Summary:
This diff adds a simple model for thrift field refs as the second argument is stored to the first
argument.

Reviewed By: rgrig

Differential Revision: D65833558

fbshipit-source-id: 90206bd0868aee872616ce80dcc22cca479801fc
  • Loading branch information
skcho authored and facebook-github-bot committed Nov 14, 2024
1 parent e18394a commit 060b3dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions infer/src/IR/Typ.mli
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ val is_shared_pointer : t -> bool

val is_folly_coro : t -> bool

val thrift_field_refs : string list

val is_thrift_field_ref : t -> bool

val is_thrift_field_ref_str : string -> bool
Expand Down
15 changes: 14 additions & 1 deletion infer/src/pulse/PulseModelsCpp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,12 @@ module Pair = struct
astate
end

module Thrift = struct
let field_ref ~name tgt src : model =
let open PulseModelsDSL.Syntax in
start_named_model ("apache::thrift::" ^ name) @@ fun () -> store ~ref:tgt src
end

let folly_co_yield_co_error : model =
let open PulseModelsDSL.Syntax in
start_named_model "folly::coro::detail::*::yield_value(folly::coro::co_error)" @@ fun () -> throw
Expand Down Expand Up @@ -1093,9 +1099,16 @@ let map_matchers =
@ folly_concurrent_hash_map_matchers @ folly_coro


let thrift_matchers =
let open ProcnameDispatcher.Call in
List.map Typ.thrift_field_refs ~f:(fun field_ref ->
-"apache" &:: "thrift" &:: field_ref &:: field_ref $ capt_arg_payload $+ capt_arg_payload
$+...$--> Thrift.field_ref ~name:field_ref )


let simple_matchers =
let open ProcnameDispatcher.Call in
map_matchers
map_matchers @ thrift_matchers
@ [ +BuiltinDecl.(match_builtin __builtin_add_overflow)
<>$ capt_arg_payload $+ capt_arg_payload $+ capt_arg_payload $--> add_overflow
|> with_non_disj
Expand Down

0 comments on commit 060b3dd

Please sign in to comment.