Skip to content

Commit 7e25b14

Browse files
committed
C#: Add test cases for finding structurally equivalent control flow elements.
1 parent 52952e9 commit 7e25b14

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
| StructuralComparison.cs:15:18:15:18 | access to field x | StructuralComparison.cs:16:18:16:18 | access to field x |
2+
| StructuralComparison.cs:15:18:15:22 | ... + ... | StructuralComparison.cs:16:18:16:22 | ... + ... |
3+
| StructuralComparison.cs:15:22:15:22 | access to field y | StructuralComparison.cs:16:22:16:22 | access to field y |
4+
| StructuralComparison.cs:16:18:16:18 | access to field x | StructuralComparison.cs:15:18:15:18 | access to field x |
5+
| StructuralComparison.cs:16:18:16:22 | ... + ... | StructuralComparison.cs:15:18:15:22 | ... + ... |
6+
| StructuralComparison.cs:16:22:16:22 | access to field y | StructuralComparison.cs:15:22:15:22 | access to field y |
7+
| StructuralComparison.cs:21:18:21:22 | call to method M1 | StructuralComparison.cs:22:18:22:22 | call to method M1 |
8+
| StructuralComparison.cs:21:21:21:21 | access to field x | StructuralComparison.cs:22:21:22:21 | access to field x |
9+
| StructuralComparison.cs:21:21:21:21 | access to field x | StructuralComparison.cs:25:21:25:21 | access to field x |
10+
| StructuralComparison.cs:21:21:21:21 | access to field x | StructuralComparison.cs:25:32:25:32 | access to field x |
11+
| StructuralComparison.cs:21:21:21:21 | access to field x | StructuralComparison.cs:26:12:26:12 | access to field x |
12+
| StructuralComparison.cs:21:21:21:21 | access to field x | StructuralComparison.cs:27:15:27:15 | access to field x |
13+
| StructuralComparison.cs:21:21:21:21 | access to field x | StructuralComparison.cs:28:15:28:15 | access to field x |
14+
| StructuralComparison.cs:22:18:22:22 | call to method M1 | StructuralComparison.cs:21:18:21:22 | call to method M1 |
15+
| StructuralComparison.cs:22:21:22:21 | access to field x | StructuralComparison.cs:21:21:21:21 | access to field x |
16+
| StructuralComparison.cs:22:21:22:21 | access to field x | StructuralComparison.cs:25:21:25:21 | access to field x |
17+
| StructuralComparison.cs:22:21:22:21 | access to field x | StructuralComparison.cs:25:32:25:32 | access to field x |
18+
| StructuralComparison.cs:22:21:22:21 | access to field x | StructuralComparison.cs:26:12:26:12 | access to field x |
19+
| StructuralComparison.cs:22:21:22:21 | access to field x | StructuralComparison.cs:27:15:27:15 | access to field x |
20+
| StructuralComparison.cs:22:21:22:21 | access to field x | StructuralComparison.cs:28:15:28:15 | access to field x |
21+
| StructuralComparison.cs:23:21:23:21 | access to field y | StructuralComparison.cs:25:24:25:24 | access to field y |
22+
| StructuralComparison.cs:23:21:23:21 | access to field y | StructuralComparison.cs:25:35:25:35 | access to field y |
23+
| StructuralComparison.cs:23:21:23:21 | access to field y | StructuralComparison.cs:26:15:26:15 | access to field y |
24+
| StructuralComparison.cs:23:21:23:21 | access to field y | StructuralComparison.cs:27:12:27:12 | access to field y |
25+
| StructuralComparison.cs:23:21:23:21 | access to field y | StructuralComparison.cs:28:12:28:12 | access to field y |
26+
| StructuralComparison.cs:25:18:25:25 | call to method M2 | StructuralComparison.cs:25:29:25:36 | call to method M2 |
27+
| StructuralComparison.cs:25:18:25:25 | call to method M2 | StructuralComparison.cs:26:9:26:16 | call to method M2 |
28+
| StructuralComparison.cs:25:21:25:21 | access to field x | StructuralComparison.cs:21:21:21:21 | access to field x |
29+
| StructuralComparison.cs:25:21:25:21 | access to field x | StructuralComparison.cs:22:21:22:21 | access to field x |
30+
| StructuralComparison.cs:25:21:25:21 | access to field x | StructuralComparison.cs:25:32:25:32 | access to field x |
31+
| StructuralComparison.cs:25:21:25:21 | access to field x | StructuralComparison.cs:26:12:26:12 | access to field x |
32+
| StructuralComparison.cs:25:21:25:21 | access to field x | StructuralComparison.cs:27:15:27:15 | access to field x |
33+
| StructuralComparison.cs:25:21:25:21 | access to field x | StructuralComparison.cs:28:15:28:15 | access to field x |
34+
| StructuralComparison.cs:25:24:25:24 | access to field y | StructuralComparison.cs:23:21:23:21 | access to field y |
35+
| StructuralComparison.cs:25:24:25:24 | access to field y | StructuralComparison.cs:25:35:25:35 | access to field y |
36+
| StructuralComparison.cs:25:24:25:24 | access to field y | StructuralComparison.cs:26:15:26:15 | access to field y |
37+
| StructuralComparison.cs:25:24:25:24 | access to field y | StructuralComparison.cs:27:12:27:12 | access to field y |
38+
| StructuralComparison.cs:25:24:25:24 | access to field y | StructuralComparison.cs:28:12:28:12 | access to field y |
39+
| StructuralComparison.cs:25:29:25:36 | call to method M2 | StructuralComparison.cs:25:18:25:25 | call to method M2 |
40+
| StructuralComparison.cs:25:29:25:36 | call to method M2 | StructuralComparison.cs:26:9:26:16 | call to method M2 |
41+
| StructuralComparison.cs:25:32:25:32 | access to field x | StructuralComparison.cs:21:21:21:21 | access to field x |
42+
| StructuralComparison.cs:25:32:25:32 | access to field x | StructuralComparison.cs:22:21:22:21 | access to field x |
43+
| StructuralComparison.cs:25:32:25:32 | access to field x | StructuralComparison.cs:25:21:25:21 | access to field x |
44+
| StructuralComparison.cs:25:32:25:32 | access to field x | StructuralComparison.cs:26:12:26:12 | access to field x |
45+
| StructuralComparison.cs:25:32:25:32 | access to field x | StructuralComparison.cs:27:15:27:15 | access to field x |
46+
| StructuralComparison.cs:25:32:25:32 | access to field x | StructuralComparison.cs:28:15:28:15 | access to field x |
47+
| StructuralComparison.cs:25:35:25:35 | access to field y | StructuralComparison.cs:23:21:23:21 | access to field y |
48+
| StructuralComparison.cs:25:35:25:35 | access to field y | StructuralComparison.cs:25:24:25:24 | access to field y |
49+
| StructuralComparison.cs:25:35:25:35 | access to field y | StructuralComparison.cs:26:15:26:15 | access to field y |
50+
| StructuralComparison.cs:25:35:25:35 | access to field y | StructuralComparison.cs:27:12:27:12 | access to field y |
51+
| StructuralComparison.cs:25:35:25:35 | access to field y | StructuralComparison.cs:28:12:28:12 | access to field y |
52+
| StructuralComparison.cs:26:9:26:16 | call to method M2 | StructuralComparison.cs:25:18:25:25 | call to method M2 |
53+
| StructuralComparison.cs:26:9:26:16 | call to method M2 | StructuralComparison.cs:25:29:25:36 | call to method M2 |
54+
| StructuralComparison.cs:26:12:26:12 | access to field x | StructuralComparison.cs:21:21:21:21 | access to field x |
55+
| StructuralComparison.cs:26:12:26:12 | access to field x | StructuralComparison.cs:22:21:22:21 | access to field x |
56+
| StructuralComparison.cs:26:12:26:12 | access to field x | StructuralComparison.cs:25:21:25:21 | access to field x |
57+
| StructuralComparison.cs:26:12:26:12 | access to field x | StructuralComparison.cs:25:32:25:32 | access to field x |
58+
| StructuralComparison.cs:26:12:26:12 | access to field x | StructuralComparison.cs:27:15:27:15 | access to field x |
59+
| StructuralComparison.cs:26:12:26:12 | access to field x | StructuralComparison.cs:28:15:28:15 | access to field x |
60+
| StructuralComparison.cs:26:15:26:15 | access to field y | StructuralComparison.cs:23:21:23:21 | access to field y |
61+
| StructuralComparison.cs:26:15:26:15 | access to field y | StructuralComparison.cs:25:24:25:24 | access to field y |
62+
| StructuralComparison.cs:26:15:26:15 | access to field y | StructuralComparison.cs:25:35:25:35 | access to field y |
63+
| StructuralComparison.cs:26:15:26:15 | access to field y | StructuralComparison.cs:27:12:27:12 | access to field y |
64+
| StructuralComparison.cs:26:15:26:15 | access to field y | StructuralComparison.cs:28:12:28:12 | access to field y |
65+
| StructuralComparison.cs:27:9:27:16 | call to method M2 | StructuralComparison.cs:28:9:28:16 | call to method M2 |
66+
| StructuralComparison.cs:27:9:27:17 | ...; | StructuralComparison.cs:28:9:28:17 | ...; |
67+
| StructuralComparison.cs:27:12:27:12 | access to field y | StructuralComparison.cs:23:21:23:21 | access to field y |
68+
| StructuralComparison.cs:27:12:27:12 | access to field y | StructuralComparison.cs:25:24:25:24 | access to field y |
69+
| StructuralComparison.cs:27:12:27:12 | access to field y | StructuralComparison.cs:25:35:25:35 | access to field y |
70+
| StructuralComparison.cs:27:12:27:12 | access to field y | StructuralComparison.cs:26:15:26:15 | access to field y |
71+
| StructuralComparison.cs:27:12:27:12 | access to field y | StructuralComparison.cs:28:12:28:12 | access to field y |
72+
| StructuralComparison.cs:27:15:27:15 | access to field x | StructuralComparison.cs:21:21:21:21 | access to field x |
73+
| StructuralComparison.cs:27:15:27:15 | access to field x | StructuralComparison.cs:22:21:22:21 | access to field x |
74+
| StructuralComparison.cs:27:15:27:15 | access to field x | StructuralComparison.cs:25:21:25:21 | access to field x |
75+
| StructuralComparison.cs:27:15:27:15 | access to field x | StructuralComparison.cs:25:32:25:32 | access to field x |
76+
| StructuralComparison.cs:27:15:27:15 | access to field x | StructuralComparison.cs:26:12:26:12 | access to field x |
77+
| StructuralComparison.cs:27:15:27:15 | access to field x | StructuralComparison.cs:28:15:28:15 | access to field x |
78+
| StructuralComparison.cs:28:9:28:16 | call to method M2 | StructuralComparison.cs:27:9:27:16 | call to method M2 |
79+
| StructuralComparison.cs:28:9:28:17 | ...; | StructuralComparison.cs:27:9:27:17 | ...; |
80+
| StructuralComparison.cs:28:12:28:12 | access to field y | StructuralComparison.cs:23:21:23:21 | access to field y |
81+
| StructuralComparison.cs:28:12:28:12 | access to field y | StructuralComparison.cs:25:24:25:24 | access to field y |
82+
| StructuralComparison.cs:28:12:28:12 | access to field y | StructuralComparison.cs:25:35:25:35 | access to field y |
83+
| StructuralComparison.cs:28:12:28:12 | access to field y | StructuralComparison.cs:26:15:26:15 | access to field y |
84+
| StructuralComparison.cs:28:12:28:12 | access to field y | StructuralComparison.cs:27:12:27:12 | access to field y |
85+
| StructuralComparison.cs:28:15:28:15 | access to field x | StructuralComparison.cs:21:21:21:21 | access to field x |
86+
| StructuralComparison.cs:28:15:28:15 | access to field x | StructuralComparison.cs:22:21:22:21 | access to field x |
87+
| StructuralComparison.cs:28:15:28:15 | access to field x | StructuralComparison.cs:25:21:25:21 | access to field x |
88+
| StructuralComparison.cs:28:15:28:15 | access to field x | StructuralComparison.cs:25:32:25:32 | access to field x |
89+
| StructuralComparison.cs:28:15:28:15 | access to field x | StructuralComparison.cs:26:12:26:12 | access to field x |
90+
| StructuralComparison.cs:28:15:28:15 | access to field x | StructuralComparison.cs:27:15:27:15 | access to field x |
91+
| StructuralComparison.cs:42:18:42:27 | access to field Field | StructuralComparison.cs:43:18:43:22 | access to field Field |
92+
| StructuralComparison.cs:42:18:42:27 | access to field Field | StructuralComparison.cs:44:18:44:27 | access to field Field |
93+
| StructuralComparison.cs:43:18:43:22 | access to field Field | StructuralComparison.cs:42:18:42:27 | access to field Field |
94+
| StructuralComparison.cs:43:18:43:22 | access to field Field | StructuralComparison.cs:44:18:44:27 | access to field Field |
95+
| StructuralComparison.cs:44:18:44:27 | access to field Field | StructuralComparison.cs:42:18:42:27 | access to field Field |
96+
| StructuralComparison.cs:44:18:44:27 | access to field Field | StructuralComparison.cs:43:18:43:22 | access to field Field |
97+
| StructuralComparison.cs:49:18:49:26 | access to property Prop | StructuralComparison.cs:50:18:50:21 | access to property Prop |
98+
| StructuralComparison.cs:49:18:49:26 | access to property Prop | StructuralComparison.cs:51:18:51:26 | access to property Prop |
99+
| StructuralComparison.cs:50:18:50:21 | access to property Prop | StructuralComparison.cs:49:18:49:26 | access to property Prop |
100+
| StructuralComparison.cs:50:18:50:21 | access to property Prop | StructuralComparison.cs:51:18:51:26 | access to property Prop |
101+
| StructuralComparison.cs:51:18:51:26 | access to property Prop | StructuralComparison.cs:49:18:49:26 | access to property Prop |
102+
| StructuralComparison.cs:51:18:51:26 | access to property Prop | StructuralComparison.cs:50:18:50:21 | access to property Prop |
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import csharp
2+
import semmle.code.csharp.commons.StructuralComparison
3+
4+
private class StructuralComparisonTest extends StructuralComparisonConfiguration {
5+
StructuralComparisonTest() { this = "StructuralComparisonTest" }
6+
7+
/**
8+
* All pairs of controls flow elements found in the source and within the same
9+
* enclosing callable excluding all instances of `ThisAccess` to reduce the size
10+
* of the output.
11+
*/
12+
override predicate candidate(ControlFlowElement e1, ControlFlowElement e2) {
13+
e1.fromSource() and
14+
e2.fromSource() and
15+
e1 != e2 and
16+
e1.getEnclosingCallable() = e2.getEnclosingCallable() and
17+
not e1 instanceof ThisAccess
18+
}
19+
}
20+
21+
query predicate same(ControlFlowElement e1, ControlFlowElement e2) {
22+
exists(StructuralComparisonTest sct | sct.same(e1, e2))
23+
}
24+
// query predicate gvn(ControlFlowElement e, Gvn gvn) { gvn = toGvn(e) and e.fromSource() }

0 commit comments

Comments
 (0)