-
Notifications
You must be signed in to change notification settings - Fork 485
Fix incorrect analysis report for optional function args #8321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
785cfb6
0678cd0
7f3772d
ad01583
4957159
61fee5f
479abea
9e41947
3ade8a0
eb38e8f
38c829f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,15 @@ let iter_function_refs t f = | |
| (fun _path items -> List.iter f items.Cross_file_items.function_refs) | ||
| r | ||
|
|
||
| let iter_optional_arg_value_escapes t f = | ||
| match t with | ||
| | Frozen cfi -> List.iter f cfi.Cross_file_items.optional_arg_value_escapes | ||
| | Reactive r -> | ||
| Reactive.iter | ||
| (fun _path items -> | ||
| List.iter f items.Cross_file_items.optional_arg_value_escapes) | ||
| r | ||
|
|
||
| (** Compute optional args state from calls and function references. | ||
| Returns a map from position to final OptionalArgs.t state. | ||
| Pure function - does not mutate declarations. *) | ||
|
|
@@ -65,3 +74,30 @@ let compute_optional_args_state (store : t) ~find_decl ~is_live : | |
| set_state pos_from updated_from; | ||
| set_state pos_to updated_to)); | ||
| state | ||
|
|
||
| let compute_live_optional_arg_value_escapes (store : t) ~is_live : Pos_set.t = | ||
| (* Compute this as a batch after solver propagation: the result depends on | ||
| final liveness and on the fully merged cross-file items. If it becomes a | ||
| cached/reactive value, both dependencies must participate in invalidation. *) | ||
| let escapes = ref Pos_set.empty in | ||
| iter_optional_arg_value_escapes store | ||
| (fun {Cross_file_items.pos_from; pos_to} -> | ||
| if is_live pos_from then escapes := Pos_set.add pos_to !escapes); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a function has both a Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is handled by closing live escapes over the live function-reference pairs in both directions, so implementation and interface declarations receive the same escape state. |
||
| let function_refs = ref [] in | ||
| iter_function_refs store (fun {Cross_file_items.pos_from; pos_to} -> | ||
| if is_live pos_from then | ||
| function_refs := (pos_from, pos_to) :: !function_refs); | ||
| (* A function reference aliases both declaration positions. Close escapes over | ||
| the undirected links so aliases and interface/implementation pairs agree. *) | ||
| let rec propagate escapes = | ||
| let propagated = | ||
| List.fold_left | ||
| (fun escapes (pos_from, pos_to) -> | ||
| if Pos_set.mem pos_from escapes then Pos_set.add pos_to escapes | ||
| else if Pos_set.mem pos_to escapes then Pos_set.add pos_from escapes | ||
| else escapes) | ||
| escapes !function_refs | ||
| in | ||
| if Pos_set.equal propagated escapes then escapes else propagate propagated | ||
| in | ||
| propagate !escapes | ||
Uh oh!
There was an error while loading. Please reload this page.