Commit Graph

868 Commits

Author SHA1 Message Date
Tom Hvitved
b7e732fddb C#: Generalize CFG entry/exit nodes to include field/property initializers 2019-08-16 13:06:51 +02:00
Calum Grant
b28241ac6d Merge pull request #1741 from hvitved/csharp/extract-field-inits
C#: Extract assignments for field/property initializers
2019-08-16 11:51:37 +01:00
Tom Hvitved
495e5bc628 C#: Extract assignments for field/property initializers 2019-08-15 16:18:23 +02:00
Calum Grant
3fab5140a7 Merge pull request #1673 from hvitved/csharp/cfg/split-static-limit
C#: Apply static CFG splitting limit
2019-08-15 10:04:38 +01:00
semmle-qlci
e27b373062 Merge pull request #1548 from hvitved/csharp/cfg/simplify-goto-completions
Approved by calumgrant
2019-08-12 19:20:48 +01:00
Tom Hvitved
5ecf680cc2 C#: Improve performance of SSA adjacent reads calculation
- Speedup the `varBlockReaches()` predicate, by restricting to basic blocks
  in which a given SSA definition may still be live, in constrast to just
  being able to reach *any* access (read or write) to the underlying source
  variable.
- Account for some missing cases in the `lastRead()` predicate.
2019-08-08 16:21:57 +02:00
Tom Hvitved
4774bc969a C#: Apply static CFG splitting limit
The predicate `maxSplits()` was previously applied dynamically to ensure that
any control flow node would keep track of at most `maxSplits()` number of splits.
However, there was no guarantee that two different copies of the same AST element
wouldn't contain different splits, so in general the number of copies for a given
AST element `e` could be on the order `$\binom{n}{k}c^k$`, where `n` is the total
number of splits that apply to `e`, `k = maxSplits()`, and `c` is a constant.

With this change, the relevant splits for `e` are instead computed statically,
meaning that the order is instead `$c^k$`.
2019-08-06 11:38:03 +02:00
Tom Hvitved
4d58154ff5 C#: Fix data flow for out/ref parameters 2019-08-02 14:25:38 -07:00
Tom Hvitved
04db1bf3f4 C#: Add data flow test for methods with multiple out/ref parameters 2019-08-02 13:46:18 -07:00
Tom Hvitved
8a35813e1c C#: Unify goto completions 2019-07-05 07:21:34 +02:00
semmle-qlci
0290c79c54 Merge pull request #1486 from hvitved/csharp/inherited-completions
Approved by calumgrant
2019-07-04 19:45:25 +01:00
Tom Hvitved
421e75d4c1 C#: Address review comments 2019-07-04 11:57:48 +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
Tom Hvitved
f91e460869 C#: Introduce inherited CFG completions
When completions are inherited by elements inside `finally` blocks, we previously
threw away the underlying completion. For example, in

```
try
{
    if (b)
        throw new Exception();
}
finally
{
    if (b)
        ...
}
```

the completions for `b` inside the `finally` block are `true` and `throw(Exception)`,
where the latter is inherited from the `try` block, with an underlying `false`
completion. Throwing away the `false` completion meant that we were unable to prune
the `false` edge (Boolean CFG splitting).
2019-06-28 15:41:49 +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
481bf77d5f CIL: Speedup consistency tests
- Make `InstructionViolation` abstract to avoid computing `getInstructionsUpTo()`
  for all instructions in the database.
- Enable `consistency.ql`, which reports all consistency violations, and remove
  all other specialized tests.
2019-06-27 13:40:07 +02:00
semmle-qlci
1c25e17812 Merge pull request #1505 from hvitved/csharp/autoformat
Approved by calumgrant
2019-06-27 08:03:58 +01:00
semmle-qlci
f58c7cc79c Merge pull request #1446 from hvitved/csharp/cached-stages
Approved by calumgrant
2019-06-27 08:03:24 +01: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
35ecb948fc C#: Fix qltests. 2019-06-26 20:24:55 +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
51d093add0 C#: Address review comments 2019-06-25 17:01:48 +02:00
Calum Grant
07eb0ec5b2 Merge pull request #1462 from hvitved/csharp/controlflowgraph-depr
C#: Remove uses of deprecated `ControlFlowGraph` module
2019-06-19 17:55:04 +01:00
Tom Hvitved
a1d7382a67 C#: Update expected test output 2019-06-17 20:07:54 +02:00
Tom Hvitved
e70f17f260 C#: Remove uses of deprecated ControlFlowGraph module 2019-06-17 10:23:23 +02:00
semmle-qlci
03cf8ef94f Merge pull request #1422 from hvitved/csharp/switch-expr-completion
Approved by calumgrant
2019-06-17 08:33:43 +01:00
Tom Hvitved
946be967f8 C#: Break up a big cached stage into multiple stages
- Add `Caching.qll` for controlling caching across multiple files.
- Move `isUncertainRefCall()` out of cached module in `Assignable.qll` to avoid
  collapsing with CFG stage.
- Remove dependency on `AlwaysNullExpr` in `NullValue::getAnExpr()` to avoid
  collapsing with CFG stage.
- Avoid caching pre-SSA library as it should only be used during the CFG construction
  stage.
2019-06-12 16:05:45 +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
Tom Hvitved
17aad4b0a5 C#: Fix CFG for switch expressions in Boolean/nullness contexts 2019-06-07 15:39:33 +02:00
Tom Hvitved
e538d8e9ac C#: Add CFG tests for switch expression in Boolean/nullness context 2019-06-07 15:39:28 +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
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
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
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
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
Calum Grant
1b264f73b4 C#: Fix test settings. 2019-05-29 08:15:51 +01:00