Commit Graph

9080 Commits

Author SHA1 Message Date
Tom Hvitved
e538d8e9ac C#: Add CFG tests for switch expression in Boolean/nullness context 2019-06-07 15:39:28 +02:00
Tom Hvitved
7c802ada40 C#: Improvements to Stubs.qll
- Handle keywords.
- Handle `const` fields.
- Handle type parameter constraints.
2019-06-07 14:50:33 +02:00
Calum Grant
c88359b9c7 C#: Fix test. 2019-06-05 09:42:48 +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
f1bb8b893b C#: Fix test. 2019-06-04 18:10:49 +01:00
Calum Grant
73c2898666 C#: Minor edits. 2019-06-04 18:10:49 +01:00
Calum Grant
5679a72f37 C#: DB Upgrade script 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
15cd1d274a C#: Implement using declaration statements. 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
ba0aab963f C#: Make csharp-alerts-lgtm a stub 2019-06-04 15:26:16 +02:00
Tom Hvitved
2d0554a7ee C#: Address review comments 2019-06-03 16:00:22 +02:00
Tom Hvitved
f95dd6bb35 Guard tests 2019-06-03 16:00:22 +02: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
032a6b1c7c Merge pull request #1375 from hvitved/csharp/switch-expr-guard
C#: Switch expression guards
2019-06-03 11:15:10 +01:00
Calum Grant
5b8c6d4789 Merge pull request #1377 from hvitved/csharp/useless-upcast
C#: Teach `cs/useless-upcast` about disambiguating constructor calls
2019-05-31 06:51:39 +01:00
Calum Grant
59a006e59e Merge pull request #1368 from hvitved/csharp/cil-nullness
CIL: Account for multiple `VariableUpdate::getSource()`s in nullness analysis
2019-05-29 20:55:08 +01:00
Tom Hvitved
6b99e1a1bf C#: Teach cs/useless-upcast about disambiguating constructor calls 2019-05-29 15:16:08 +02:00
Tom Hvitved
d8482083b9 C#: Add tests for disambiguated constructor calls 2019-05-29 15:14:30 +02:00
Tom Hvitved
884ef4c960 Merge pull request #1362 from calumgrant/cs/cs8/testing
C#: Various small C#8 features
2019-05-29 14:00:43 +02:00
Tom Hvitved
c68dfb9d68 C#: Switch expression guards 2019-05-29 13:50:42 +02:00
Tom Hvitved
23ce5bc7bf Merge pull request #1353 from calumgrant/cs/diagnostic-queries3
C#: Add internal queries for extractor and compiler diagnostics
2019-05-29 10:26:41 +02:00
Tom Hvitved
428ad72694 C#: Improve performance of always[Not]NullMethod() 2019-05-29 09:34:54 +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
Calum Grant
85f275ce73 Merge pull request #1347 from hvitved/csharp/dataflow/this-flow
C#: Data flow through `this` parameter
2019-05-28 19:58:01 +01:00
Tom Hvitved
0ee5fe88d9 CIL: Account for multiple VariableUpdate::getSource()s in nullness analysis
For methods compiled without optimization (and possibly also with optimization),
it is possible for a variable update to have multiple possible assigned values.
For example, the non-optimized CIL for

```
return cond ? null : "not null"
```

is

```
0: nop
1: ldarg.0
2: ldfld cond
3: brtrue.s 6:
4: ldstr "not null"
5: br.s 7:
6: ldnull
7: stloc.0 L0 // stores either `null` or "not null"
8: br.s 9:
9: ldloc.0
10: ret
```

Consequently, an existential in `CallableReturns.qll` must be a `forex`.
2019-05-28 10:13:00 +02:00
Tom Hvitved
4fc61ebbf3 C#: Add tests for maybe-null CIL methods 2019-05-28 10:05:33 +02:00
Tom Hvitved
c82a2f0fec C#: Refactor data flow predicates to be defined by dispatch 2019-05-27 13:40:41 +02:00
Calum Grant
ae8ecc88e6 C#: Address review comments. 2019-05-24 14:56:58 +01:00
Calum Grant
d2aea635e4 C#: Address review comments 2019-05-24 13:49:05 +01:00
Calum Grant
14147a1abe C#: DB upgrade script and stats 2019-05-24 13:49:05 +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 Grant
21203cdf0d C#: Minor code tidy. 2019-05-24 13:49:05 +01:00
Calum Grant
aecc9e2a57 C#: Fix LGTM warnings 2019-05-24 13:49:05 +01:00
Calum Grant
55b41cfaf7 C#: DB Upgrade script 2019-05-24 13:49:05 +01:00
Calum Grant
1a40c29aba C#: DB stats 2019-05-24 13:49:05 +01:00
Calum Grant
fa57017720 C#: Minor edit. 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
Tom Hvitved
d30bce4f31 C#: Update expected test output 2019-05-23 16:03:54 +02:00
Calum Grant
fcfb7b2b8a C#: Fix error caused by Roslyn upgrade. 2019-05-22 16:17:16 +01:00
Calum Grant
e5aa7f3ba7 C#: Upgrade to Roslyn 3.1 2019-05-22 15:54:30 +01:00
Calum Grant
fc8eccfc6b C#: Add some basic qhelp. Since these are internal queries, this is probably not needed. 2019-05-22 10:16:24 +01:00
Denis Levin
0b108fab0f Replaced tabs with spaces 2019-05-21 14:11:30 -07:00