Skip to content

Commit

Permalink
[const refable] Suppress issue on folly::coro::Generator
Browse files Browse the repository at this point in the history
Summary:
This diff suppresses const refable issues on folly's coroutine generator procedures, because
reference parameters may introduce dangling pointer issue.

https://en.cppreference.com/w/cpp/language/coroutines

> copies all function parameters to the coroutine state: by-value parameters are moved or copied,
by-reference parameters remain references (thus, may become dangling, if the coroutine is resumed
after the lifetime of referred object ends ...).

Reviewed By: bennostein

Differential Revision: D45814146

fbshipit-source-id: 93e7a48520f60614bae76a33a6f846f002881cdf
  • Loading branch information
skcho authored and facebook-github-bot committed May 12, 2023
1 parent a063217 commit e7f8cbe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions infer/src/pulse/PulseNonDisjunctiveOperations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,10 @@ let call tenv proc_desc path loc ~call_exp ~actuals ~astates_before astates asta
(astate_n, astates)


let is_folly_coro_task =
let matcher = QualifiedCppName.Match.of_fuzzy_qual_names ["folly::coro::Task"] in
let is_folly_coro =
let matcher =
QualifiedCppName.Match.of_fuzzy_qual_names ["folly::coro::Generator"; "folly::coro::Task"]
in
fun typ ->
match typ.Typ.desc with
| Tptr ({desc= Tstruct (CppClass {name})}, _) ->
Expand All @@ -529,7 +531,7 @@ let is_folly_coro_task =

let init_const_refable_parameters procdesc integer_type_widths tenv astates astate_n =
if
Option.exists (Procdesc.get_ret_param_type procdesc) ~f:is_folly_coro_task
Option.exists (Procdesc.get_ret_param_type procdesc) ~f:is_folly_coro
|| Procname.is_lambda_or_block (Procdesc.get_proc_name procdesc)
then astate_n
else
Expand Down

0 comments on commit e7f8cbe

Please sign in to comment.