Commit Graph

90 Commits

Author SHA1 Message Date
Calum Grant
ead916702a C#: Take nullability into account when creating symbol entities. Otherwise, an entity with the wrong (cached) nullability could be created. 2020-04-20 11:29:31 +01:00
Calum Grant
abf6be6030 C#: Avoid qualifying explicit interface implementations. 2020-04-07 11:17:35 +01:00
Calum Grant
d0d7ed620c C#: Update comments in test file to reflect fixed test output. 2020-01-07 18:39:52 +00:00
Calum Grant
359dea2c2b C#: Fixed test output. 2020-01-07 18:39:52 +00:00
Calum Grant
85c9459b35 C#: Add more tests showing incorrect extraction. 2020-01-07 18:39:51 +00:00
Calum Grant
10181e93e2 C#: Update QLtest output 2020-01-07 18:39:51 +00:00
Calum Grant
8db46bc8ec C#: More tests for nullable flow state. 2020-01-07 18:38:58 +00:00
Calum Grant
6c9ebaba0b C#: Populate expression type nullability and nullable flow state. 2020-01-07 18:38:58 +00:00
Calum Grant
0327b83958 C#: Update nullability tests. 2020-01-07 18:38:58 +00:00
Calum Grant
5e6b7be5b8 C#: Update nullability tests. 2019-12-06 12:41:20 +00:00
Calum Grant
aac360463b C#: Tests for default interface methods. 2019-11-15 10:13:04 +00:00
Calum Grant
ce188c0c22 C#: Autoformat 2019-11-12 13:40:58 +00:00
Calum Grant
f00276a82c C#: Remove non-essential changes 2019-11-12 13:40:58 +00:00
Calum Grant
a0fa7dad79 C#: Autoformat 2019-11-12 13:40:58 +00:00
Calum Grant
9fd4a9ceb6 C#: Implement NullabilityEntity to model structured nullability on the side 2019-11-12 13:40:57 +00:00
Calum Grant
61ab9431ab C#: Fix DB inconsistencies, and rework id generation. 2019-11-12 13:40:57 +00:00
Tom Hvitved
5d140930d0 C#: Add field initializers to CFG for constructors
This commit adds field initializers to the CFG for non-static constructors. For
example, in

```
class C
{
    int Field1 = 0;
    int Field2 = Field1 + 1;
    int Field3;

    public C()
    {
        Field3 = 2;
    }

    public C(int i)
    {
        Field3 = 3;
    }
}
```

the initializer expressions `Field1 = 0` and `Field2 = Field1 + 1` are added
to the two constructors, mimicking

```
public C()
{
    Field1 = 0;
    Field2 = Field1 + 1;
    Field3 = 2;
}
```

and

```
public C()
{
    Field1 = 0;
    Field2 = Field1 + 1;
    Field3 = 3;
}
```

respectively. This means that we no longer have to synthesize calls, callables,
parameters, and arguments in the data flow library, so much of the work from
d1755500e4 can be simplified.
2019-08-21 16:21:38 +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
Arthur Baars
af68fd4904 Merge pull request #1408 from calumgrant/cs/suppress-null-expr
C#: C#8 Nullable expressions and type annotations
2019-06-28 19:21:46 +02:00
Calum Grant
76454ed68a C#: Fix formatting of arrays and NullableTypes 2019-06-26 20:24:56 +01:00
Calum Grant
abf43dabe5 C#: Address review comments. Fix up toStringWithTypes(), and deprecate predicates in TypeParameterConstraints. 2019-06-26 20:24:56 +01:00
Calum Grant
4aa1947a23 C#: Implement type annotations for nullability, parameter kinds and method returns. 2019-06-26 20:24:55 +01:00
Tom Hvitved
bd03e7a590 C#: Auto format 2019-06-26 19:32:08 +02:00
Tom Hvitved
e70f17f260 C#: Remove uses of deprecated ControlFlowGraph module 2019-06-17 10:23:23 +02:00
Calum Grant
40481fbf9d C#: Make SuppressNullableWarningExpr a nonNullValue, and add a test. 2019-06-11 12:45:50 +01:00
Calum Grant
d48ce859eb C#: Implement nullable warning suppression expressions. 2019-06-11 12:12:29 +01:00
Calum Grant
9678f8eaba C#: Fix control flow graph for using declaration statements. 2019-06-04 18:10:49 +01:00
Calum Grant
20752c80c9 C#: Address review comments 2019-06-04 18:10:49 +01:00
Calum Grant
d6fac7bfb7 C#: Delete file. 2019-06-04 18:10:49 +01:00
Calum Grant
fa89d2b845 C#: Update stats and test output. 2019-06-04 18:10:49 +01:00
Calum Grant
923fbe4c9e C#: Implement QL model for using declarations, introducing UsingBlockStmt and a UsingDeclStmt. 2019-06-04 18:10:49 +01:00
Calum Grant
ac3a06f77b C#: Implement null coalescing assignment operator 2019-06-04 18:10:49 +01:00
Calum Grant
599a5b1eef C#: Make @local_function @modifiable, make LocalFunction extend Modifiable, and extract modifiers for local functions. 2019-06-04 18:10:49 +01:00
Tom Hvitved
25cb01ffea C#: Handle discard variable declarations in switch expressions 2019-06-03 15:50:41 +02:00
Tom Hvitved
8c1cab2d03 C#: Simplify extraction of is expressions and case statements 2019-06-03 15:50:41 +02:00
Calum Grant
1b264f73b4 C#: Fix test settings. 2019-05-29 08:15:51 +01:00
Calum Grant
573646fe6a C#: Various C#8 features:
- Async streams (test only)
 - Unmanaged generic structs (extractor support)
 - Alternate interpolated strings (test only)
 - static local function (test only)
2019-05-29 08:12:11 +01:00
Tom Hvitved
a1e58cedac C#: Refactor recursive patterns implementation
- Extract names of properties in a propery match, using the `exprorstmt_name` relation.
- Simplify extraction of properties by not distinguishing between top-level patterns
  and nested patterns.
- Introduce `PatternExpr` to capture patterns in `is` expressions, `case` statements,
  and `switch` expression arms.
- Generalize `IsTypeExpr`, `IsPatternExpr`, `IsRecursivePatternExpr`, and `IsConstantExpr`
  to just `IsExpr` with a member predicate `PatternExpr getPattern()`.
- Generalize `TypeCase`, `RecursivePatternCase`, and `ConstCase` to just `CaseStmt` with
  a member predicate `PatternExpr getPattern()`.
- Introduce classes `Switch` and `Case` as base classes of switch statements/expressions
  and case statements/switch expression arms, respectively.
- Simplify CFG logic using the generalized classes.
- Generalize guards library to cover `switch` expressions tests.
- Generalize data flow library to cover `switch` expression assignments.
2019-05-24 13:49:05 +01:00
calum
1428d0ba93 C#: Implement recursive patterns 2019-05-24 13:49:05 +01:00
calum
318068b52f C#: Implement range operator 2019-05-24 13:49:04 +01:00