Commit Graph

63 Commits

Author SHA1 Message Date
Anders Schack-Mulligen
7e4e872430 C#: Accept expected changes. 2025-12-02 13:49:16 +01:00
Tom Hvitved
a991ef0f87 C#: Add a CFG test for switch fall-through 2025-04-25 10:32:48 +02:00
Michael Nebel
5ae7e5ddb3 C#: Update other test expected output files. 2025-03-21 13:23:11 +01:00
Tom Hvitved
1c344d6735 C#: Adjust conditional access locations 2024-04-10 16:21:58 +02:00
Michael Nebel
a4ab163532 C#: Update test output for cfg tests. 2024-02-22 13:33:29 +01:00
Tom Hvitved
f85fa87f69 C#: Add test that illustrates problem with getEnclosingCallable 2021-11-24 13:59:29 +01:00
Tamas Vajk
b7f13a7e1f C#: Change generic method names to include <> and type args/params 2021-09-06 11:48:22 +02:00
Tom Hvitved
633f228dc2 C#: Add CFG tests for partial classes 2021-05-03 10:23:29 +02:00
Tom Hvitved
c3890a9435 C#: Adjust CFG for instance constructors 2021-04-29 14:05:42 +02:00
Tom Hvitved
249e431e87 C#: Adjust CFG for {Recursive,Positional,Property}PatternExpr 2021-02-01 13:52:18 +01:00
Tamas Vajk
a9c51e7300 Fix missing pattern matching completions 2021-01-29 15:16:30 +01:00
Tamas Vajk
10518744cf C#: Remove expressions inside attributes from CFG 2021-01-27 13:20:06 +01:00
Tamas Vajk
e24e5b13f5 C#: Improve CFG to handle 'and' and 'or' patterns 2021-01-27 11:52:59 +01:00
Tom Hvitved
39977e9a43 Merge pull request #4724 from hvitved/csharp/cfg/not-pattern
C#: Implement CFG for `not` patterns
2021-01-27 10:12:31 +01:00
Tom Hvitved
07a96c3596 C#: Add CFG tests for ExceptionDispatchInfo::Throw 2021-01-26 09:01:06 +01:00
Tom Hvitved
e0c7f32282 C#: Add relational pattern CFG test 2021-01-25 13:52:17 +01:00
Tom Hvitved
0080357153 C#: Add unary pattern CFG tests 2021-01-25 13:52:17 +01:00
Tamas Vajk
5803a449be Add test case for assign operation in finally 2021-01-14 08:39:46 +01:00
Tom Hvitved
9afce31e92 C#: Add one more CFG test for nested finally blocks 2020-12-04 13:26:00 +01:00
Tom Hvitved
94deed39a2 C#: Represent all expressions in post-order in the CFG 2020-11-12 20:04:48 +01:00
Tamas Vajk
453c97a8c3 Fix expected files of failing tests 2020-11-11 09:57:52 +01:00
Tom Hvitved
ade8ff9593 C#: Add more CFG tests 2020-10-30 09:14:12 +01:00
Tom Hvitved
5cd707f17e C#: Add CFG test for assertion with multiple assertion arguments 2020-10-29 15:44:13 +01:00
Tom Hvitved
ca4e5014ae C#: Include compiler-generated array lengths in the CFG 2020-10-08 10:35:50 +02:00
Tom Hvitved
ce8567c64a Merge pull request #4293 from hvitved/csharp/cfg/assertions
C#: Model assertions in the CFG
2020-10-08 10:32:13 +02:00
Tom Hvitved
9c503c1591 C#: Add more data/control-flow tests 2020-10-07 17:10:01 +02:00
Tom Hvitved
17f0ac4b20 C#: Add more CFG assertion tests 2020-10-02 15:35:33 +02:00
Tamas Vajk
48bf6d55aa C#: Add implicit cast from array to pointer 2020-09-23 17:21:38 +02:00
Tom Hvitved
9e240b7397 C#: Add more CFG loop unrolling tests 2020-09-07 15:26:25 +02:00
Tom Hvitved
c7f776984f C#: Add CFG tests for callables with multiple implementations 2020-09-02 10:52:05 +02:00
Tom Hvitved
090205d9e9 C#: Add CFG test for conditional call to method with out parameter 2020-07-02 13:09:40 +02:00
Tom Hvitved
7a54a90e61 C#: Fix CFG for C# 6 initializers 2020-05-20 12:01:22 +02:00
Tom Hvitved
36e29e0f75 C#: Add CFG tests for C# 6 initializers 2020-05-20 09:33:51 +02:00
Tom Hvitved
bd075a7de0 C#: Add CFG test 2020-04-23 08:45:11 +02:00
Calum Grant
81110dca0a C#: Add new test for switch statements. 2019-09-20 14:22:31 +01:00
Tom Hvitved
b9fa837963 C#: Add new CFG test for try/finally 2019-09-12 11:44:04 +02:00
Tom Hvitved
3d32f3d173 C#: Restructure existing CFG tests for try/finally 2019-09-12 11:44:04 +02:00
Tom Hvitved
1bfef706e2 C#: Add loop unrolling tests 2019-09-01 10:34:51 +02:00
Calum Grant
83ab044a73 C#: Update expected test output. 2019-08-29 18:12:58 +01:00
Tom Hvitved
d2f8b0bc20 C#: Handle constructors with member initializers and base() calls in CFG 2019-08-22 10:34:23 +02: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
495e5bc628 C#: Extract assignments for field/property initializers 2019-08-15 16:18:23 +02:00
Tom Hvitved
8d7ea2f49f C#: Add CFG test that mixes Boolean/finally/catch splitting 2019-06-28 15:41:49 +02:00
Tom Hvitved
e538d8e9ac C#: Add CFG tests for switch expression in Boolean/nullness context 2019-06-07 15:39:28 +02:00
Tom Hvitved
25cb01ffea C#: Handle discard variable declarations in switch expressions 2019-06-03 15:50:41 +02: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
Tom Hvitved
fcad129135 C#: Add CFG tests for (potential) dynamic accessor calls 2019-04-09 15:26:36 +02:00
Tom Hvitved
5ce9b25ec9 C#: Improve CFG for assignments
Write accesses in assignments, such as the access to `x` in `x = 0` are not
evaluated, so they should not have entries in the control flow graph. However,
qualifiers (and indexer arguments) should still be evaluated, for example in

```
x.Foo.Bar = 0;
```

the CFG should be `x --> x.Foo --> 0 --> x.Foo.Bar = 0` (as opposed to
`x --> x.Foo --> x.Foo.Bar --> 0 --> x.Foo.Bar = 0`, prior to this change).

A special case is assignments via acessors (properties, indexers, and event
adders), where we do want to include the access in the control flow graph,
as it represents the accessor call:

```
x.Prop = 0;
```

But instead of `x --> x.set_Prop --> 0 --> x.Prop = 0` the CFG should be
`x --> 0 --> x.set_Prop --> x.Prop = 0`, as the setter is called *after* the
assigned value has been evaluated.

An even more special case is tuple assignments via accessors:

```
(x.Prop1, y.Prop2) = (0, 1);
```

Here the CFG should be
`x --> y --> 0 --> 1 --> x.set_Prop1 --> y.set_Prop2 --> (x.Prop1, y.Prop2) = (0, 1)`.
2019-02-16 19:19:24 +01:00
Tom Hvitved
096757dadf C#: Add CFG tests for accessor calls 2019-02-14 20:24:04 +01:00