Skip to content

Commit 3236cbd

Browse files
committed
C++: Test the AST wrapper for IR GVN
Out of our 3 GVN libraries, the one we actually use in production didn't have tests -- except indirectly through `diff_ir_expr.ql`.
1 parent 49f902d commit 3236cbd

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
| test.cpp:5:3:5:3 | GVN | 5:c3-c3 6:c3-c3 |
2+
| test.cpp:5:7:5:8 | GVN | 5:c7-c8 6:c7-c8 |
3+
| test.cpp:5:7:5:13 | GVN | 5:c7-c13 6:c7-c13 7:c7-c7 |
4+
| test.cpp:5:12:5:13 | GVN | 5:c12-c13 6:c12-c13 |
5+
| test.cpp:16:3:16:3 | GVN | 16:c3-c3 17:c3-c3 |
6+
| test.cpp:16:7:16:8 | GVN | 16:c7-c8 17:c7-c8 |
7+
| test.cpp:16:7:16:13 | GVN | 16:c7-c13 17:c7-c13 |
8+
| test.cpp:16:7:16:24 | GVN | 16:c7-c24 17:c7-c24 18:c7-c7 |
9+
| test.cpp:16:12:16:13 | GVN | 16:c12-c13 17:c12-c13 |
10+
| test.cpp:16:17:16:24 | GVN | 16:c17-c24 17:c17-c24 |
11+
| test.cpp:29:3:29:3 | GVN | 29:c3-c3 31:c3-c3 |
12+
| test.cpp:29:7:29:8 | GVN | 29:c7-c8 31:c7-c8 |
13+
| test.cpp:29:7:29:13 | GVN | 29:c7-c13 31:c7-c13 |
14+
| test.cpp:29:12:29:13 | GVN | 29:c12-c13 31:c12-c13 |
15+
| test.cpp:31:7:31:24 | GVN | 31:c7-c24 32:c7-c7 |
16+
| test.cpp:43:3:43:3 | GVN | 43:c3-c3 45:c3-c3 |
17+
| test.cpp:43:7:43:8 | GVN | 43:c7-c8 45:c7-c8 |
18+
| test.cpp:43:7:43:13 | GVN | 43:c7-c13 45:c7-c13 |
19+
| test.cpp:43:7:43:24 | GVN | 43:c7-c24 45:c7-c24 46:c7-c7 |
20+
| test.cpp:43:12:43:13 | GVN | 43:c12-c13 45:c12-c13 |
21+
| test.cpp:43:17:43:24 | GVN | 43:c17-c24 45:c17-c24 |
22+
| test.cpp:44:3:44:5 | GVN | 44:c3-c5 44:c4-c5 |
23+
| test.cpp:53:10:53:13 | GVN | 53:c10-c13 56:c21-c24 |
24+
| test.cpp:53:10:53:13 | GVN | 53:c10-c13 56:c21-c24 |
25+
| test.cpp:53:11:53:13 | GVN | 53:c11-c13 56:c22-c24 |
26+
| test.cpp:53:18:53:21 | GVN | 53:c18-c21 56:c39-c42 59:c17-c20 |
27+
| test.cpp:56:13:56:16 | GVN | 56:c13-c16 56:c31-c34 59:c9-c12 |
28+
| test.cpp:56:13:56:16 | GVN | 56:c13-c16 56:c31-c34 59:c9-c12 |
29+
| test.cpp:56:14:56:16 | GVN | 56:c14-c16 56:c32-c34 56:c47-c49 59:c10-c12 |
30+
| test.cpp:62:5:62:10 | GVN | 62:c5-c10 65:c10-c15 |
31+
| test.cpp:77:20:77:28 | GVN | 77:c20-c28 79:c7-c7 |
32+
| test.cpp:79:11:79:14 | GVN | 79:c11-c14 79:c24-c27 |
33+
| test.cpp:92:11:92:16 | GVN | 92:c11-c16 92:c15-c16 93:c10-c10 |
34+
| test.cpp:105:11:105:12 | GVN | 105:c11-c12 106:c33-c34 |
35+
| test.cpp:105:11:105:12 | GVN | 105:c11-c12 106:c33-c34 107:c11-c12 |
36+
| test.cpp:105:15:105:15 | GVN | 105:c15-c15 107:c15-c15 109:c10-c10 |
37+
| test.cpp:113:3:113:5 | GVN | 113:c3-c5 115:c3-c5 |
38+
| test.cpp:125:11:125:12 | GVN | 125:c11-c12 126:c11-c12 128:c3-c4 129:c11-c12 |
39+
| test.cpp:125:15:125:15 | GVN | 125:c15-c15 126:c15-c15 |
40+
| test.cpp:128:11:128:11 | GVN | 128:c11-c11 129:c15-c15 |
41+
| test.cpp:136:11:136:18 | GVN | 136:c11-c18 137:c11-c18 139:c3-c10 |
42+
| test.cpp:136:21:136:21 | GVN | 136:c21-c21 137:c21-c21 |
43+
| test.cpp:144:11:144:12 | GVN | 144:c11-c12 145:c11-c12 147:c3-c4 149:c11-c12 |
44+
| test.cpp:144:15:144:15 | GVN | 144:c15-c15 149:c15-c15 |
45+
| test.cpp:153:11:153:18 | GVN | 153:c11-c18 154:c11-c18 156:c3-c10 |
46+
| test.cpp:153:21:153:21 | GVN | 153:c21-c21 154:c21-c21 |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import cpp
2+
import semmle.code.cpp.ir.internal.ASTValueNumbering
3+
4+
from GVN g
5+
where strictcount(g.getAnExpr()) > 1
6+
select g,
7+
strictconcat(Location loc |
8+
loc = g.getAnExpr().getLocation()
9+
|
10+
loc.getStartLine() + ":c" + loc.getStartColumn() + "-c" + loc.getEndColumn(), " "
11+
)

0 commit comments

Comments
 (0)