Skip to content

Commit 610be85

Browse files
committed
C#: Add CFG test for multiple-field Boolean splitting
1 parent 41edd61 commit 610be85

12 files changed

+141
-0
lines changed

csharp/ql/test/library-tests/controlflow/graph/BasicBlock.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@
171171
| Conditions.cs:117:9:123:9 | {...} | Conditions.cs:119:18:119:21 | access to local variable last | 13 |
172172
| Conditions.cs:120:17:120:23 | [last (line 118): false] ...; | Conditions.cs:121:17:121:20 | [last (line 118): false] access to local variable last | 6 |
173173
| Conditions.cs:121:13:122:25 | [last (line 118): true] if (...) ... | Conditions.cs:122:17:122:24 | ... = ... | 6 |
174+
| Conditions.cs:129:10:129:12 | enter M10 | Conditions.cs:133:17:133:22 | access to field Field1 | 8 |
175+
| Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true | Conditions.cs:133:17:133:22 | [Field1 (line 129): false] access to field Field1 | 5 |
176+
| Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} | Conditions.cs:135:21:135:26 | [Field1 (line 129): true] access to field Field2 | 4 |
174177
| ExitMethods.cs:7:10:7:11 | enter M1 | ExitMethods.cs:7:10:7:11 | exit M1 | 7 |
175178
| ExitMethods.cs:13:10:13:11 | enter M2 | ExitMethods.cs:13:10:13:11 | exit M2 | 7 |
176179
| ExitMethods.cs:19:10:19:11 | enter M3 | ExitMethods.cs:19:10:19:11 | exit M3 | 6 |

csharp/ql/test/library-tests/controlflow/graph/BasicBlockDominance.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@
381381
| post | Conditions.cs:117:9:123:9 | {...} | Conditions.cs:117:9:123:9 | {...} |
382382
| post | Conditions.cs:120:17:120:23 | [last (line 118): false] ...; | Conditions.cs:120:17:120:23 | [last (line 118): false] ...; |
383383
| post | Conditions.cs:121:13:122:25 | [last (line 118): true] if (...) ... | Conditions.cs:121:13:122:25 | [last (line 118): true] if (...) ... |
384+
| post | Conditions.cs:129:10:129:12 | enter M10 | Conditions.cs:129:10:129:12 | enter M10 |
385+
| post | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true |
386+
| post | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} |
384387
| post | ExitMethods.cs:7:10:7:11 | enter M1 | ExitMethods.cs:7:10:7:11 | enter M1 |
385388
| post | ExitMethods.cs:13:10:13:11 | enter M2 | ExitMethods.cs:13:10:13:11 | enter M2 |
386389
| post | ExitMethods.cs:19:10:19:11 | enter M3 | ExitMethods.cs:19:10:19:11 | enter M3 |
@@ -1747,6 +1750,11 @@
17471750
| pre | Conditions.cs:117:9:123:9 | {...} | Conditions.cs:121:13:122:25 | [last (line 118): true] if (...) ... |
17481751
| pre | Conditions.cs:120:17:120:23 | [last (line 118): false] ...; | Conditions.cs:120:17:120:23 | [last (line 118): false] ...; |
17491752
| pre | Conditions.cs:121:13:122:25 | [last (line 118): true] if (...) ... | Conditions.cs:121:13:122:25 | [last (line 118): true] if (...) ... |
1753+
| pre | Conditions.cs:129:10:129:12 | enter M10 | Conditions.cs:129:10:129:12 | enter M10 |
1754+
| pre | Conditions.cs:129:10:129:12 | enter M10 | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true |
1755+
| pre | Conditions.cs:129:10:129:12 | enter M10 | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} |
1756+
| pre | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true |
1757+
| pre | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} |
17501758
| pre | ExitMethods.cs:7:10:7:11 | enter M1 | ExitMethods.cs:7:10:7:11 | enter M1 |
17511759
| pre | ExitMethods.cs:13:10:13:11 | enter M2 | ExitMethods.cs:13:10:13:11 | enter M2 |
17521760
| pre | ExitMethods.cs:19:10:19:11 | enter M3 | ExitMethods.cs:19:10:19:11 | enter M3 |

csharp/ql/test/library-tests/controlflow/graph/BooleanNode.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
| Field1 (line 129): false | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true |
2+
| Field1 (line 129): false | Conditions.cs:132:9:140:9 | [Field1 (line 129): false] {...} |
3+
| Field1 (line 129): false | Conditions.cs:133:13:139:13 | [Field1 (line 129): false] if (...) ... |
4+
| Field1 (line 129): false | Conditions.cs:133:17:133:22 | [Field1 (line 129): false] access to field Field1 |
5+
| Field1 (line 129): false | Conditions.cs:133:17:133:22 | [Field1 (line 129): false] this access |
6+
| Field1 (line 129): true | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} |
7+
| Field1 (line 129): true | Conditions.cs:135:17:138:17 | [Field1 (line 129): true] if (...) ... |
8+
| Field1 (line 129): true | Conditions.cs:135:21:135:26 | [Field1 (line 129): true] access to field Field2 |
9+
| Field1 (line 129): true | Conditions.cs:135:21:135:26 | [Field1 (line 129): true] this access |
110
| b2 (line 22): false | Conditions.cs:28:9:29:16 | [b2 (line 22): false] if (...) ... |
211
| b2 (line 22): false | Conditions.cs:28:13:28:14 | [b2 (line 22): false] access to parameter b2 |
312
| b2 (line 22): true | Conditions.cs:27:17:27:17 | [b2 (line 22): true] access to local variable x |

csharp/ql/test/library-tests/controlflow/graph/ConditionBlock.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@
162162
| Conditions.cs:116:24:116:38 | ... < ... | Conditions.cs:121:13:122:25 | [last (line 118): true] if (...) ... | true |
163163
| Conditions.cs:119:18:119:21 | access to local variable last | Conditions.cs:120:17:120:23 | [last (line 118): false] ...; | false |
164164
| Conditions.cs:119:18:119:21 | access to local variable last | Conditions.cs:121:13:122:25 | [last (line 118): true] if (...) ... | true |
165+
| Conditions.cs:133:17:133:22 | access to field Field1 | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true | false |
166+
| Conditions.cs:133:17:133:22 | access to field Field1 | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} | true |
165167
| ExitMethods.cs:43:9:46:9 | [exception: Exception] catch (...) {...} | ExitMethods.cs:47:9:50:9 | [exception: Exception] catch (...) {...} | false |
166168
| ExitMethods.cs:55:13:55:13 | access to parameter b | ExitMethods.cs:56:19:56:33 | object creation of type Exception | true |
167169
| ExitMethods.cs:61:13:61:13 | access to parameter b | ExitMethods.cs:62:19:62:33 | object creation of type Exception | true |

csharp/ql/test/library-tests/controlflow/graph/ConditionalFlow.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@
199199
| 121 | 17 | Conditions.cs:121:17:121:20 | [last (line 118): true] access to local variable last | true | 122 | 17 | Conditions.cs:122:17:122:25 | ...; |
200200
| 127 | 32 | cflow.cs:127:32:127:44 | ... == ... | false | 127 | 53 | cflow.cs:127:53:127:57 | this access |
201201
| 127 | 32 | cflow.cs:127:32:127:44 | ... == ... | true | 127 | 48 | cflow.cs:127:48:127:49 | "" |
202+
| 131 | 16 | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true | true | 132 | 9 | Conditions.cs:132:9:140:9 | [Field1 (line 129): false] {...} |
203+
| 131 | 16 | Conditions.cs:131:16:131:19 | true | true | 132 | 9 | Conditions.cs:132:9:140:9 | {...} |
204+
| 133 | 17 | Conditions.cs:133:17:133:22 | [Field1 (line 129): false] access to field Field1 | false | 131 | 16 | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true |
205+
| 133 | 17 | Conditions.cs:133:17:133:22 | access to field Field1 | false | 131 | 16 | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true |
206+
| 133 | 17 | Conditions.cs:133:17:133:22 | access to field Field1 | true | 134 | 13 | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} |
202207
| 162 | 48 | cflow.cs:162:48:162:51 | [exception: Exception] true | true | 163 | 9 | cflow.cs:163:9:165:9 | {...} |
203208
| 170 | 21 | cflow.cs:170:21:170:24 | true | true | 170 | 27 | cflow.cs:170:27:170:32 | throw ...; |
204209
| 194 | 48 | cflow.cs:194:48:194:51 | [exception: Exception] true | true | 195 | 9 | cflow.cs:195:9:197:9 | {...} |

csharp/ql/test/library-tests/controlflow/graph/Conditions.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,21 @@ void M9(string[] args)
122122
s = null;
123123
}
124124
}
125+
126+
private bool Field1;
127+
private bool Field2;
128+
129+
void M10()
130+
{
131+
while (true)
132+
{
133+
if (Field1)
134+
{
135+
if (Field2)
136+
{
137+
Field1.ToString();
138+
}
139+
}
140+
}
141+
}
125142
}

csharp/ql/test/library-tests/controlflow/graph/Dominance.expected

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,20 @@
661661
| post | Conditions.cs:122:17:122:24 | ... = ... | Conditions.cs:122:21:122:24 | null |
662662
| post | Conditions.cs:122:17:122:25 | ...; | Conditions.cs:121:17:121:20 | [last (line 118): true] access to local variable last |
663663
| post | Conditions.cs:122:21:122:24 | null | Conditions.cs:122:17:122:17 | access to local variable s |
664+
| post | Conditions.cs:130:5:141:5 | {...} | Conditions.cs:129:10:129:12 | enter M10 |
665+
| post | Conditions.cs:131:9:140:9 | while (...) ... | Conditions.cs:130:5:141:5 | {...} |
666+
| post | Conditions.cs:131:16:131:19 | true | Conditions.cs:131:9:140:9 | while (...) ... |
667+
| post | Conditions.cs:132:9:140:9 | [Field1 (line 129): false] {...} | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true |
668+
| post | Conditions.cs:132:9:140:9 | {...} | Conditions.cs:131:16:131:19 | true |
669+
| post | Conditions.cs:133:13:139:13 | [Field1 (line 129): false] if (...) ... | Conditions.cs:132:9:140:9 | [Field1 (line 129): false] {...} |
670+
| post | Conditions.cs:133:13:139:13 | if (...) ... | Conditions.cs:132:9:140:9 | {...} |
671+
| post | Conditions.cs:133:17:133:22 | [Field1 (line 129): false] access to field Field1 | Conditions.cs:133:17:133:22 | [Field1 (line 129): false] this access |
672+
| post | Conditions.cs:133:17:133:22 | [Field1 (line 129): false] this access | Conditions.cs:133:13:139:13 | [Field1 (line 129): false] if (...) ... |
673+
| post | Conditions.cs:133:17:133:22 | access to field Field1 | Conditions.cs:133:17:133:22 | this access |
674+
| post | Conditions.cs:133:17:133:22 | this access | Conditions.cs:133:13:139:13 | if (...) ... |
675+
| post | Conditions.cs:135:17:138:17 | [Field1 (line 129): true] if (...) ... | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} |
676+
| post | Conditions.cs:135:21:135:26 | [Field1 (line 129): true] access to field Field2 | Conditions.cs:135:21:135:26 | [Field1 (line 129): true] this access |
677+
| post | Conditions.cs:135:21:135:26 | [Field1 (line 129): true] this access | Conditions.cs:135:17:138:17 | [Field1 (line 129): true] if (...) ... |
664678
| post | ExitMethods.cs:7:10:7:11 | exit M1 | ExitMethods.cs:10:9:10:15 | return ...; |
665679
| post | ExitMethods.cs:8:5:11:5 | {...} | ExitMethods.cs:7:10:7:11 | enter M1 |
666680
| post | ExitMethods.cs:9:9:9:24 | call to method ErrorMaybe | ExitMethods.cs:9:20:9:23 | true |
@@ -2828,6 +2842,22 @@
28282842
| pre | Conditions.cs:122:17:122:17 | access to local variable s | Conditions.cs:122:21:122:24 | null |
28292843
| pre | Conditions.cs:122:17:122:25 | ...; | Conditions.cs:122:17:122:17 | access to local variable s |
28302844
| pre | Conditions.cs:122:21:122:24 | null | Conditions.cs:122:17:122:24 | ... = ... |
2845+
| pre | Conditions.cs:129:10:129:12 | enter M10 | Conditions.cs:130:5:141:5 | {...} |
2846+
| pre | Conditions.cs:130:5:141:5 | {...} | Conditions.cs:131:9:140:9 | while (...) ... |
2847+
| pre | Conditions.cs:131:9:140:9 | while (...) ... | Conditions.cs:131:16:131:19 | true |
2848+
| pre | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true | Conditions.cs:132:9:140:9 | [Field1 (line 129): false] {...} |
2849+
| pre | Conditions.cs:131:16:131:19 | true | Conditions.cs:132:9:140:9 | {...} |
2850+
| pre | Conditions.cs:132:9:140:9 | [Field1 (line 129): false] {...} | Conditions.cs:133:13:139:13 | [Field1 (line 129): false] if (...) ... |
2851+
| pre | Conditions.cs:132:9:140:9 | {...} | Conditions.cs:133:13:139:13 | if (...) ... |
2852+
| pre | Conditions.cs:133:13:139:13 | [Field1 (line 129): false] if (...) ... | Conditions.cs:133:17:133:22 | [Field1 (line 129): false] this access |
2853+
| pre | Conditions.cs:133:13:139:13 | if (...) ... | Conditions.cs:133:17:133:22 | this access |
2854+
| pre | Conditions.cs:133:17:133:22 | [Field1 (line 129): false] this access | Conditions.cs:133:17:133:22 | [Field1 (line 129): false] access to field Field1 |
2855+
| pre | Conditions.cs:133:17:133:22 | access to field Field1 | Conditions.cs:131:16:131:19 | [Field1 (line 129): false] true |
2856+
| pre | Conditions.cs:133:17:133:22 | access to field Field1 | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} |
2857+
| pre | Conditions.cs:133:17:133:22 | this access | Conditions.cs:133:17:133:22 | access to field Field1 |
2858+
| pre | Conditions.cs:134:13:139:13 | [Field1 (line 129): true] {...} | Conditions.cs:135:17:138:17 | [Field1 (line 129): true] if (...) ... |
2859+
| pre | Conditions.cs:135:17:138:17 | [Field1 (line 129): true] if (...) ... | Conditions.cs:135:21:135:26 | [Field1 (line 129): true] this access |
2860+
| pre | Conditions.cs:135:21:135:26 | [Field1 (line 129): true] this access | Conditions.cs:135:21:135:26 | [Field1 (line 129): true] access to field Field2 |
28312861
| pre | ExitMethods.cs:7:10:7:11 | enter M1 | ExitMethods.cs:8:5:11:5 | {...} |
28322862
| pre | ExitMethods.cs:8:5:11:5 | {...} | ExitMethods.cs:9:9:9:25 | ...; |
28332863
| pre | ExitMethods.cs:9:9:9:24 | call to method ErrorMaybe | ExitMethods.cs:10:9:10:15 | return ...; |

csharp/ql/test/library-tests/controlflow/graph/ElementGraph.expected

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,17 @@
514514
| Conditions.cs:122:17:122:24 | ... = ... | Conditions.cs:116:41:116:41 | access to local variable i | semmle.label | successor |
515515
| Conditions.cs:122:17:122:25 | ...; | Conditions.cs:122:17:122:17 | access to local variable s | semmle.label | successor |
516516
| Conditions.cs:122:21:122:24 | null | Conditions.cs:122:17:122:24 | ... = ... | semmle.label | successor |
517+
| Conditions.cs:130:5:141:5 | {...} | Conditions.cs:131:9:140:9 | while (...) ... | semmle.label | successor |
518+
| Conditions.cs:131:9:140:9 | while (...) ... | Conditions.cs:131:16:131:19 | true | semmle.label | successor |
519+
| Conditions.cs:131:16:131:19 | true | Conditions.cs:132:9:140:9 | {...} | semmle.label | true |
520+
| Conditions.cs:132:9:140:9 | {...} | Conditions.cs:133:13:139:13 | if (...) ... | semmle.label | successor |
521+
| Conditions.cs:133:13:139:13 | if (...) ... | Conditions.cs:133:17:133:22 | this access | semmle.label | successor |
522+
| Conditions.cs:133:17:133:22 | access to field Field1 | Conditions.cs:131:16:131:19 | true | semmle.label | false |
523+
| Conditions.cs:133:17:133:22 | access to field Field1 | Conditions.cs:134:13:139:13 | {...} | semmle.label | true |
524+
| Conditions.cs:133:17:133:22 | this access | Conditions.cs:133:17:133:22 | access to field Field1 | semmle.label | successor |
525+
| Conditions.cs:134:13:139:13 | {...} | Conditions.cs:135:17:138:17 | if (...) ... | semmle.label | successor |
526+
| Conditions.cs:135:17:138:17 | if (...) ... | Conditions.cs:135:21:135:26 | this access | semmle.label | successor |
527+
| Conditions.cs:135:21:135:26 | this access | Conditions.cs:135:21:135:26 | access to field Field2 | semmle.label | successor |
517528
| ExitMethods.cs:8:5:11:5 | {...} | ExitMethods.cs:9:9:9:25 | ...; | semmle.label | successor |
518529
| ExitMethods.cs:9:9:9:24 | call to method ErrorMaybe | ExitMethods.cs:10:9:10:15 | return ...; | semmle.label | successor |
519530
| ExitMethods.cs:9:9:9:25 | ...; | ExitMethods.cs:9:20:9:23 | true | semmle.label | successor |

csharp/ql/test/library-tests/controlflow/graph/EntryElement.expected

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,22 @@
516516
| Conditions.cs:122:17:122:24 | ... = ... | Conditions.cs:122:17:122:17 | access to local variable s |
517517
| Conditions.cs:122:17:122:25 | ...; | Conditions.cs:122:17:122:25 | ...; |
518518
| Conditions.cs:122:21:122:24 | null | Conditions.cs:122:21:122:24 | null |
519+
| Conditions.cs:130:5:141:5 | {...} | Conditions.cs:130:5:141:5 | {...} |
520+
| Conditions.cs:131:9:140:9 | while (...) ... | Conditions.cs:131:9:140:9 | while (...) ... |
521+
| Conditions.cs:131:16:131:19 | true | Conditions.cs:131:16:131:19 | true |
522+
| Conditions.cs:132:9:140:9 | {...} | Conditions.cs:132:9:140:9 | {...} |
523+
| Conditions.cs:133:13:139:13 | if (...) ... | Conditions.cs:133:13:139:13 | if (...) ... |
524+
| Conditions.cs:133:17:133:22 | access to field Field1 | Conditions.cs:133:17:133:22 | this access |
525+
| Conditions.cs:133:17:133:22 | this access | Conditions.cs:133:17:133:22 | this access |
526+
| Conditions.cs:134:13:139:13 | {...} | Conditions.cs:134:13:139:13 | {...} |
527+
| Conditions.cs:135:17:138:17 | if (...) ... | Conditions.cs:135:17:138:17 | if (...) ... |
528+
| Conditions.cs:135:21:135:26 | access to field Field2 | Conditions.cs:135:21:135:26 | this access |
529+
| Conditions.cs:135:21:135:26 | this access | Conditions.cs:135:21:135:26 | this access |
530+
| Conditions.cs:136:17:138:17 | {...} | Conditions.cs:136:17:138:17 | {...} |
531+
| Conditions.cs:137:21:137:26 | access to field Field1 | Conditions.cs:137:21:137:26 | this access |
532+
| Conditions.cs:137:21:137:26 | this access | Conditions.cs:137:21:137:26 | this access |
533+
| Conditions.cs:137:21:137:37 | call to method ToString | Conditions.cs:137:21:137:26 | this access |
534+
| Conditions.cs:137:21:137:38 | ...; | Conditions.cs:137:21:137:38 | ...; |
519535
| ExitMethods.cs:8:5:11:5 | {...} | ExitMethods.cs:8:5:11:5 | {...} |
520536
| ExitMethods.cs:9:9:9:24 | call to method ErrorMaybe | ExitMethods.cs:9:20:9:23 | true |
521537
| ExitMethods.cs:9:9:9:25 | ...; | ExitMethods.cs:9:9:9:25 | ...; |

csharp/ql/test/library-tests/controlflow/graph/EntryPoint.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
| Conditions.cs:86:9:86:10 | M7 | Conditions.cs:87:5:100:5 | {...} |
3434
| Conditions.cs:102:12:102:13 | M8 | Conditions.cs:103:5:111:5 | {...} |
3535
| Conditions.cs:113:10:113:11 | M9 | Conditions.cs:114:5:124:5 | {...} |
36+
| Conditions.cs:129:10:129:12 | M10 | Conditions.cs:130:5:141:5 | {...} |
3637
| ExitMethods.cs:7:10:7:11 | M1 | ExitMethods.cs:8:5:11:5 | {...} |
3738
| ExitMethods.cs:13:10:13:11 | M2 | ExitMethods.cs:14:5:17:5 | {...} |
3839
| ExitMethods.cs:19:10:19:11 | M3 | ExitMethods.cs:20:5:23:5 | {...} |

0 commit comments

Comments
 (0)