Commit Graph

3 Commits

Author SHA1 Message Date
Michael Nebel
4dfeff38f9 C#: Add dataflow field test for ref structs with ref and ordinary fields. 2024-02-01 15:04:06 +01:00
Tom Hvitved
083214f85a C#: Use inline test expectations for FieldFlow.ql 2021-10-14 15:22:21 +02:00
Tom Hvitved
d1755500e4 C#: Data flow through fields
Initial implementation of data flow through fields, using the algorithm of the
shared data flow implementation. Fields (and field-like properties) are covered,
and stores can be either
 - ordinary assignments, `Foo = x`,
 - object initializers, `new C() { Foo = x }`, or
 - field initializers, `int Foo = x`.

For field initializers, we need to synthesize calls (`SynthesizedCall`),
callables (`SynthesizedCallable`), parameters (`InstanceParameterNode`), and
arguments (`SynthesizedThisArgumentNode`), as the C# extractor does not (yet)
extract such entities. For example, in

```
class C
{
    int Field1 = 1;
    int Field2 = 2;

    C() { }
}
```

there is a synthesized call from the constructor `C`, with a synthesized `this`
argument, and the targets of that call are two synthesized callables with bodies
`this.Field1 = 1` and `this.Field2 = 2`, respectively.

A consequence of this is that `DataFlowCallable` is no longer an alias for
`DotNet::Callable`, but instead an IPA type.
2019-08-16 15:49:37 +02:00