Skip to content

Commit e02c0f6

Browse files
committed
C#: Add CFG test for method with default parameters
1 parent c64223a commit e02c0f6

7 files changed

Lines changed: 75 additions & 0 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@
433433
| Conditions.cs:146:9:149:49 | After if (...) ... | Conditions.cs:143:10:143:12 | Exit | 4 |
434434
| Conditions.cs:146:13:146:13 | After access to parameter b [false] | Conditions.cs:149:13:149:49 | After ...; | 14 |
435435
| Conditions.cs:146:13:146:13 | After access to parameter b [true] | Conditions.cs:147:13:147:49 | After ...; | 14 |
436+
| DefaultParam.cs:1:7:1:18 | Entry | DefaultParam.cs:1:7:1:18 | Exit | 11 |
437+
| DefaultParam.cs:3:10:3:11 | Entry | DefaultParam.cs:3:10:3:11 | Exit | 4 |
436438
| ExitMethods.cs:6:7:6:17 | Entry | ExitMethods.cs:6:7:6:17 | Exit | 11 |
437439
| ExitMethods.cs:8:10:8:11 | Entry | ExitMethods.cs:8:10:8:11 | Exit | 12 |
438440
| ExitMethods.cs:14:10:14:11 | Entry | ExitMethods.cs:14:10:14:11 | Exit | 12 |
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class DefaultParam
2+
{
3+
void M1(bool b, string s = "", int i = 0)
4+
{
5+
6+
}
7+
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,6 +2642,19 @@ dominance
26422642
| Conditions.cs:149:44:149:46 | Before {...} | Conditions.cs:149:45:149:45 | access to local variable s |
26432643
| Conditions.cs:149:44:149:46 | {...} | Conditions.cs:149:44:149:46 | After {...} |
26442644
| Conditions.cs:149:45:149:45 | access to local variable s | Conditions.cs:149:44:149:46 | {...} |
2645+
| DefaultParam.cs:1:7:1:18 | After call to constructor Object | DefaultParam.cs:1:7:1:18 | {...} |
2646+
| DefaultParam.cs:1:7:1:18 | After call to method <object initializer> | DefaultParam.cs:1:7:1:18 | Before call to constructor Object |
2647+
| DefaultParam.cs:1:7:1:18 | Before call to constructor Object | DefaultParam.cs:1:7:1:18 | call to constructor Object |
2648+
| DefaultParam.cs:1:7:1:18 | Before call to method <object initializer> | DefaultParam.cs:1:7:1:18 | this access |
2649+
| DefaultParam.cs:1:7:1:18 | Entry | DefaultParam.cs:1:7:1:18 | Before call to method <object initializer> |
2650+
| DefaultParam.cs:1:7:1:18 | Normal Exit | DefaultParam.cs:1:7:1:18 | Exit |
2651+
| DefaultParam.cs:1:7:1:18 | call to constructor Object | DefaultParam.cs:1:7:1:18 | After call to constructor Object |
2652+
| DefaultParam.cs:1:7:1:18 | call to method <object initializer> | DefaultParam.cs:1:7:1:18 | After call to method <object initializer> |
2653+
| DefaultParam.cs:1:7:1:18 | this access | DefaultParam.cs:1:7:1:18 | call to method <object initializer> |
2654+
| DefaultParam.cs:1:7:1:18 | {...} | DefaultParam.cs:1:7:1:18 | Normal Exit |
2655+
| DefaultParam.cs:3:10:3:11 | Entry | DefaultParam.cs:4:5:6:5 | {...} |
2656+
| DefaultParam.cs:3:10:3:11 | Normal Exit | DefaultParam.cs:3:10:3:11 | Exit |
2657+
| DefaultParam.cs:4:5:6:5 | {...} | DefaultParam.cs:3:10:3:11 | Normal Exit |
26452658
| ExitMethods.cs:6:7:6:17 | After call to constructor Object | ExitMethods.cs:6:7:6:17 | {...} |
26462659
| ExitMethods.cs:6:7:6:17 | After call to method <object initializer> | ExitMethods.cs:6:7:6:17 | Before call to constructor Object |
26472660
| ExitMethods.cs:6:7:6:17 | Before call to constructor Object | ExitMethods.cs:6:7:6:17 | call to constructor Object |
@@ -10119,6 +10132,19 @@ postDominance
1011910132
| Conditions.cs:149:44:149:46 | Before {...} | Conditions.cs:149:40:149:43 | "b = " |
1012010133
| Conditions.cs:149:44:149:46 | {...} | Conditions.cs:149:45:149:45 | access to local variable s |
1012110134
| Conditions.cs:149:45:149:45 | access to local variable s | Conditions.cs:149:44:149:46 | Before {...} |
10135+
| DefaultParam.cs:1:7:1:18 | After call to constructor Object | DefaultParam.cs:1:7:1:18 | call to constructor Object |
10136+
| DefaultParam.cs:1:7:1:18 | After call to method <object initializer> | DefaultParam.cs:1:7:1:18 | call to method <object initializer> |
10137+
| DefaultParam.cs:1:7:1:18 | Before call to constructor Object | DefaultParam.cs:1:7:1:18 | After call to method <object initializer> |
10138+
| DefaultParam.cs:1:7:1:18 | Before call to method <object initializer> | DefaultParam.cs:1:7:1:18 | Entry |
10139+
| DefaultParam.cs:1:7:1:18 | Exit | DefaultParam.cs:1:7:1:18 | Normal Exit |
10140+
| DefaultParam.cs:1:7:1:18 | Normal Exit | DefaultParam.cs:1:7:1:18 | {...} |
10141+
| DefaultParam.cs:1:7:1:18 | call to constructor Object | DefaultParam.cs:1:7:1:18 | Before call to constructor Object |
10142+
| DefaultParam.cs:1:7:1:18 | call to method <object initializer> | DefaultParam.cs:1:7:1:18 | this access |
10143+
| DefaultParam.cs:1:7:1:18 | this access | DefaultParam.cs:1:7:1:18 | Before call to method <object initializer> |
10144+
| DefaultParam.cs:1:7:1:18 | {...} | DefaultParam.cs:1:7:1:18 | After call to constructor Object |
10145+
| DefaultParam.cs:3:10:3:11 | Exit | DefaultParam.cs:3:10:3:11 | Normal Exit |
10146+
| DefaultParam.cs:3:10:3:11 | Normal Exit | DefaultParam.cs:4:5:6:5 | {...} |
10147+
| DefaultParam.cs:4:5:6:5 | {...} | DefaultParam.cs:3:10:3:11 | Entry |
1012210148
| ExitMethods.cs:6:7:6:17 | After call to constructor Object | ExitMethods.cs:6:7:6:17 | call to constructor Object |
1012310149
| ExitMethods.cs:6:7:6:17 | After call to method <object initializer> | ExitMethods.cs:6:7:6:17 | call to method <object initializer> |
1012410150
| ExitMethods.cs:6:7:6:17 | Before call to constructor Object | ExitMethods.cs:6:7:6:17 | After call to method <object initializer> |
@@ -16742,6 +16768,8 @@ blockDominance
1674216768
| Conditions.cs:146:9:149:49 | After if (...) ... | Conditions.cs:146:9:149:49 | After if (...) ... |
1674316769
| Conditions.cs:146:13:146:13 | After access to parameter b [false] | Conditions.cs:146:13:146:13 | After access to parameter b [false] |
1674416770
| Conditions.cs:146:13:146:13 | After access to parameter b [true] | Conditions.cs:146:13:146:13 | After access to parameter b [true] |
16771+
| DefaultParam.cs:1:7:1:18 | Entry | DefaultParam.cs:1:7:1:18 | Entry |
16772+
| DefaultParam.cs:3:10:3:11 | Entry | DefaultParam.cs:3:10:3:11 | Entry |
1674516773
| ExitMethods.cs:6:7:6:17 | Entry | ExitMethods.cs:6:7:6:17 | Entry |
1674616774
| ExitMethods.cs:8:10:8:11 | Entry | ExitMethods.cs:8:10:8:11 | Entry |
1674716775
| ExitMethods.cs:14:10:14:11 | Entry | ExitMethods.cs:14:10:14:11 | Entry |
@@ -20977,6 +21005,8 @@ postBlockDominance
2097721005
| Conditions.cs:146:9:149:49 | After if (...) ... | Conditions.cs:146:13:146:13 | After access to parameter b [true] |
2097821006
| Conditions.cs:146:13:146:13 | After access to parameter b [false] | Conditions.cs:146:13:146:13 | After access to parameter b [false] |
2097921007
| Conditions.cs:146:13:146:13 | After access to parameter b [true] | Conditions.cs:146:13:146:13 | After access to parameter b [true] |
21008+
| DefaultParam.cs:1:7:1:18 | Entry | DefaultParam.cs:1:7:1:18 | Entry |
21009+
| DefaultParam.cs:3:10:3:11 | Entry | DefaultParam.cs:3:10:3:11 | Entry |
2098021010
| ExitMethods.cs:6:7:6:17 | Entry | ExitMethods.cs:6:7:6:17 | Entry |
2098121011
| ExitMethods.cs:8:10:8:11 | Entry | ExitMethods.cs:8:10:8:11 | Entry |
2098221012
| ExitMethods.cs:14:10:14:11 | Entry | ExitMethods.cs:14:10:14:11 | Entry |

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,21 @@ nodeEnclosing
28292829
| Conditions.cs:149:44:149:46 | Before {...} | Conditions.cs:143:10:143:12 | M11 |
28302830
| Conditions.cs:149:44:149:46 | {...} | Conditions.cs:143:10:143:12 | M11 |
28312831
| Conditions.cs:149:45:149:45 | access to local variable s | Conditions.cs:143:10:143:12 | M11 |
2832+
| DefaultParam.cs:1:7:1:18 | After call to constructor Object | DefaultParam.cs:1:7:1:18 | DefaultParam |
2833+
| DefaultParam.cs:1:7:1:18 | After call to method <object initializer> | DefaultParam.cs:1:7:1:18 | DefaultParam |
2834+
| DefaultParam.cs:1:7:1:18 | Before call to constructor Object | DefaultParam.cs:1:7:1:18 | DefaultParam |
2835+
| DefaultParam.cs:1:7:1:18 | Before call to method <object initializer> | DefaultParam.cs:1:7:1:18 | DefaultParam |
2836+
| DefaultParam.cs:1:7:1:18 | Entry | DefaultParam.cs:1:7:1:18 | DefaultParam |
2837+
| DefaultParam.cs:1:7:1:18 | Exit | DefaultParam.cs:1:7:1:18 | DefaultParam |
2838+
| DefaultParam.cs:1:7:1:18 | Normal Exit | DefaultParam.cs:1:7:1:18 | DefaultParam |
2839+
| DefaultParam.cs:1:7:1:18 | call to constructor Object | DefaultParam.cs:1:7:1:18 | DefaultParam |
2840+
| DefaultParam.cs:1:7:1:18 | call to method <object initializer> | DefaultParam.cs:1:7:1:18 | DefaultParam |
2841+
| DefaultParam.cs:1:7:1:18 | this access | DefaultParam.cs:1:7:1:18 | DefaultParam |
2842+
| DefaultParam.cs:1:7:1:18 | {...} | DefaultParam.cs:1:7:1:18 | DefaultParam |
2843+
| DefaultParam.cs:3:10:3:11 | Entry | DefaultParam.cs:3:10:3:11 | M1 |
2844+
| DefaultParam.cs:3:10:3:11 | Exit | DefaultParam.cs:3:10:3:11 | M1 |
2845+
| DefaultParam.cs:3:10:3:11 | Normal Exit | DefaultParam.cs:3:10:3:11 | M1 |
2846+
| DefaultParam.cs:4:5:6:5 | {...} | DefaultParam.cs:3:10:3:11 | M1 |
28322847
| ExitMethods.cs:6:7:6:17 | After call to constructor Object | ExitMethods.cs:6:7:6:17 | ExitMethods |
28332848
| ExitMethods.cs:6:7:6:17 | After call to method <object initializer> | ExitMethods.cs:6:7:6:17 | ExitMethods |
28342849
| ExitMethods.cs:6:7:6:17 | Before call to constructor Object | ExitMethods.cs:6:7:6:17 | ExitMethods |
@@ -8487,6 +8502,8 @@ blockEnclosing
84878502
| Conditions.cs:146:9:149:49 | After if (...) ... | Conditions.cs:143:10:143:12 | M11 |
84888503
| Conditions.cs:146:13:146:13 | After access to parameter b [false] | Conditions.cs:143:10:143:12 | M11 |
84898504
| Conditions.cs:146:13:146:13 | After access to parameter b [true] | Conditions.cs:143:10:143:12 | M11 |
8505+
| DefaultParam.cs:1:7:1:18 | Entry | DefaultParam.cs:1:7:1:18 | DefaultParam |
8506+
| DefaultParam.cs:3:10:3:11 | Entry | DefaultParam.cs:3:10:3:11 | M1 |
84908507
| ExitMethods.cs:6:7:6:17 | Entry | ExitMethods.cs:6:7:6:17 | ExitMethods |
84918508
| ExitMethods.cs:8:10:8:11 | Entry | ExitMethods.cs:8:10:8:11 | M1 |
84928509
| ExitMethods.cs:14:10:14:11 | Entry | ExitMethods.cs:14:10:14:11 | M2 |

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,11 @@
12711271
| Conditions.cs:149:40:149:43 | "b = " | Conditions.cs:149:40:149:43 | "b = " |
12721272
| Conditions.cs:149:44:149:46 | {...} | Conditions.cs:149:45:149:45 | access to local variable s |
12731273
| Conditions.cs:149:45:149:45 | access to local variable s | Conditions.cs:149:45:149:45 | access to local variable s |
1274+
| DefaultParam.cs:1:7:1:18 | call to constructor Object | DefaultParam.cs:1:7:1:18 | call to constructor Object |
1275+
| DefaultParam.cs:1:7:1:18 | call to method <object initializer> | DefaultParam.cs:1:7:1:18 | this access |
1276+
| DefaultParam.cs:1:7:1:18 | this access | DefaultParam.cs:1:7:1:18 | this access |
1277+
| DefaultParam.cs:1:7:1:18 | {...} | DefaultParam.cs:1:7:1:18 | {...} |
1278+
| DefaultParam.cs:4:5:6:5 | {...} | DefaultParam.cs:4:5:6:5 | {...} |
12741279
| ExitMethods.cs:6:7:6:17 | call to constructor Object | ExitMethods.cs:6:7:6:17 | call to constructor Object |
12751280
| ExitMethods.cs:6:7:6:17 | call to method <object initializer> | ExitMethods.cs:6:7:6:17 | this access |
12761281
| ExitMethods.cs:6:7:6:17 | this access | ExitMethods.cs:6:7:6:17 | this access |

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,6 +2882,19 @@
28822882
| Conditions.cs:149:44:149:46 | Before {...} | Conditions.cs:149:45:149:45 | access to local variable s | |
28832883
| Conditions.cs:149:44:149:46 | {...} | Conditions.cs:149:44:149:46 | After {...} | |
28842884
| Conditions.cs:149:45:149:45 | access to local variable s | Conditions.cs:149:44:149:46 | {...} | |
2885+
| DefaultParam.cs:1:7:1:18 | After call to constructor Object | DefaultParam.cs:1:7:1:18 | {...} | |
2886+
| DefaultParam.cs:1:7:1:18 | After call to method <object initializer> | DefaultParam.cs:1:7:1:18 | Before call to constructor Object | |
2887+
| DefaultParam.cs:1:7:1:18 | Before call to constructor Object | DefaultParam.cs:1:7:1:18 | call to constructor Object | |
2888+
| DefaultParam.cs:1:7:1:18 | Before call to method <object initializer> | DefaultParam.cs:1:7:1:18 | this access | |
2889+
| DefaultParam.cs:1:7:1:18 | Entry | DefaultParam.cs:1:7:1:18 | Before call to method <object initializer> | |
2890+
| DefaultParam.cs:1:7:1:18 | Normal Exit | DefaultParam.cs:1:7:1:18 | Exit | |
2891+
| DefaultParam.cs:1:7:1:18 | call to constructor Object | DefaultParam.cs:1:7:1:18 | After call to constructor Object | |
2892+
| DefaultParam.cs:1:7:1:18 | call to method <object initializer> | DefaultParam.cs:1:7:1:18 | After call to method <object initializer> | |
2893+
| DefaultParam.cs:1:7:1:18 | this access | DefaultParam.cs:1:7:1:18 | call to method <object initializer> | |
2894+
| DefaultParam.cs:1:7:1:18 | {...} | DefaultParam.cs:1:7:1:18 | Normal Exit | |
2895+
| DefaultParam.cs:3:10:3:11 | Entry | DefaultParam.cs:4:5:6:5 | {...} | |
2896+
| DefaultParam.cs:3:10:3:11 | Normal Exit | DefaultParam.cs:3:10:3:11 | Exit | |
2897+
| DefaultParam.cs:4:5:6:5 | {...} | DefaultParam.cs:3:10:3:11 | Normal Exit | |
28852898
| ExitMethods.cs:6:7:6:17 | After call to constructor Object | ExitMethods.cs:6:7:6:17 | {...} | |
28862899
| ExitMethods.cs:6:7:6:17 | After call to method <object initializer> | ExitMethods.cs:6:7:6:17 | Before call to constructor Object | |
28872900
| ExitMethods.cs:6:7:6:17 | Before call to constructor Object | ExitMethods.cs:6:7:6:17 | call to constructor Object | |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
| Conditions.cs:113:10:113:11 | M9 | Conditions.cs:114:5:124:5 | {...} |
6060
| Conditions.cs:129:10:129:12 | M10 | Conditions.cs:130:5:141:5 | {...} |
6161
| Conditions.cs:143:10:143:12 | M11 | Conditions.cs:144:5:150:5 | {...} |
62+
| DefaultParam.cs:3:10:3:11 | M1 | DefaultParam.cs:4:5:6:5 | {...} |
6263
| ExitMethods.cs:8:10:8:11 | M1 | ExitMethods.cs:9:5:12:5 | {...} |
6364
| ExitMethods.cs:14:10:14:11 | M2 | ExitMethods.cs:15:5:18:5 | {...} |
6465
| ExitMethods.cs:20:10:20:11 | M3 | ExitMethods.cs:21:5:24:5 | {...} |

0 commit comments

Comments
 (0)