-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Data flow: Add hook for preventing lambda dispatch in source call contexts #21592
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -63,6 +63,35 @@ signature module InputSig<LocationSig Location> { | |
|
|
||
| DataFlowType getNodeType(Node node); | ||
|
|
||
| /** | ||
| * Gets a special type to use for parameter nodes belonging to callables with a | ||
| * source node where a source call context `FlowFeature` is used, if any. | ||
| * | ||
| * This can be used to prevent lambdas from being resolved, when a concrete call | ||
| * context is needed. Example: | ||
hvitved marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * | ||
| * ```csharp | ||
| * void Foo(Action<string> a) | ||
| * { | ||
| * var x = Source(); | ||
| * a(x); // (1) | ||
| * a = s => Sink(s); // (2) | ||
| * a(x); // (3) | ||
| * } | ||
| * | ||
| * void Bar() | ||
| * { | ||
| * Foo(s => Sink(s)); // (4) | ||
| * } | ||
| * ``` | ||
| * | ||
| * If a source call context flow feature is used, `a` can be assigned a special | ||
| * type that is incompatible with the type of _any_ lambda expression, which will | ||
| * prevent the call edge from (1) to (4). Note that the call edge from (3) to (2) | ||
| * will still be valid. | ||
| */ | ||
| default DataFlowType getSourceContextParameterNodeType() { none() } | ||
|
Contributor
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. I wonder whether this type ought to be parameterised on the parameter. Conceptually it's a subtype of whatever callback type the parameter has and there could be multiple mutually disjoint callback types. And if this type is introduced as a singleton then it could conceptually ruin that disjointness. |
||
|
|
||
| predicate nodeIsHidden(Node node); | ||
|
|
||
| class DataFlowExpr; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.