Skip to content

Commit 0d181a7

Browse files
committed
C++: Add tests and accept output
1 parent 69e085d commit 0d181a7

File tree

4 files changed

+168
-0
lines changed

4 files changed

+168
-0
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
| test.cpp:5:3:5:13 | ... = ... | test.cpp:5:3:5:13 | ... = ... | AST only |
2+
| test.cpp:6:3:6:13 | ... = ... | test.cpp:6:3:6:13 | ... = ... | AST only |
3+
| test.cpp:7:3:7:7 | ... = ... | test.cpp:7:3:7:7 | ... = ... | AST only |
4+
| test.cpp:10:16:10:16 | 1 | test.cpp:10:16:10:16 | 1 | AST only |
5+
| test.cpp:16:3:16:24 | ... = ... | test.cpp:16:3:16:24 | ... = ... | AST only |
6+
| test.cpp:16:7:16:24 | ... + ... | test.cpp:17:7:17:24 | ... + ... | AST only |
7+
| test.cpp:16:7:16:24 | ... + ... | test.cpp:18:7:18:7 | x | AST only |
8+
| test.cpp:16:17:16:24 | global01 | test.cpp:17:17:17:24 | global01 | AST only |
9+
| test.cpp:17:3:17:24 | ... = ... | test.cpp:17:3:17:24 | ... = ... | AST only |
10+
| test.cpp:17:7:17:24 | ... + ... | test.cpp:16:7:16:24 | ... + ... | AST only |
11+
| test.cpp:17:17:17:24 | global01 | test.cpp:16:17:16:24 | global01 | AST only |
12+
| test.cpp:18:3:18:7 | ... = ... | test.cpp:18:3:18:7 | ... = ... | AST only |
13+
| test.cpp:18:7:18:7 | x | test.cpp:16:7:16:24 | ... + ... | AST only |
14+
| test.cpp:21:16:21:16 | 2 | test.cpp:21:16:21:16 | 2 | AST only |
15+
| test.cpp:29:3:29:3 | x | test.cpp:31:3:31:3 | x | IR only |
16+
| test.cpp:29:3:29:24 | ... = ... | test.cpp:29:3:29:24 | ... = ... | AST only |
17+
| test.cpp:30:3:30:17 | call to change_global02 | test.cpp:30:3:30:17 | call to change_global02 | AST only |
18+
| test.cpp:31:3:31:3 | x | test.cpp:29:3:29:3 | x | IR only |
19+
| test.cpp:31:3:31:24 | ... = ... | test.cpp:31:3:31:24 | ... = ... | AST only |
20+
| test.cpp:32:3:32:7 | ... = ... | test.cpp:32:3:32:7 | ... = ... | AST only |
21+
| test.cpp:35:16:35:16 | 3 | test.cpp:35:16:35:16 | 3 | AST only |
22+
| test.cpp:43:3:43:3 | x | test.cpp:45:3:45:3 | x | IR only |
23+
| test.cpp:43:3:43:24 | ... = ... | test.cpp:43:3:43:24 | ... = ... | AST only |
24+
| test.cpp:44:3:44:5 | * ... | test.cpp:44:4:44:5 | p2 | IR only |
25+
| test.cpp:44:3:44:9 | ... = ... | test.cpp:44:3:44:9 | ... = ... | AST only |
26+
| test.cpp:44:4:44:5 | p2 | test.cpp:44:3:44:5 | * ... | IR only |
27+
| test.cpp:44:9:44:9 | 0 | test.cpp:51:25:51:25 | 0 | AST only |
28+
| test.cpp:44:9:44:9 | 0 | test.cpp:53:18:53:21 | (int)... | AST only |
29+
| test.cpp:44:9:44:9 | 0 | test.cpp:56:39:56:42 | (int)... | AST only |
30+
| test.cpp:44:9:44:9 | 0 | test.cpp:59:17:59:20 | (int)... | AST only |
31+
| test.cpp:44:9:44:9 | 0 | test.cpp:88:12:88:12 | 0 | AST only |
32+
| test.cpp:45:3:45:3 | x | test.cpp:43:3:43:3 | x | IR only |
33+
| test.cpp:45:3:45:24 | ... = ... | test.cpp:45:3:45:24 | ... = ... | AST only |
34+
| test.cpp:46:3:46:7 | ... = ... | test.cpp:46:3:46:7 | ... = ... | AST only |
35+
| test.cpp:51:25:51:25 | 0 | test.cpp:44:9:44:9 | 0 | AST only |
36+
| test.cpp:51:25:51:25 | 0 | test.cpp:53:18:53:21 | (int)... | AST only |
37+
| test.cpp:51:25:51:25 | 0 | test.cpp:56:39:56:42 | (int)... | AST only |
38+
| test.cpp:51:25:51:25 | 0 | test.cpp:59:17:59:20 | (int)... | AST only |
39+
| test.cpp:51:25:51:25 | 0 | test.cpp:88:12:88:12 | 0 | AST only |
40+
| test.cpp:51:25:51:25 | (unsigned int)... | test.cpp:51:25:51:25 | (unsigned int)... | AST only |
41+
| test.cpp:53:10:53:13 | (int)... | test.cpp:53:10:53:13 | (int)... | AST only |
42+
| test.cpp:53:10:53:13 | (int)... | test.cpp:56:21:56:24 | (int)... | AST only |
43+
| test.cpp:53:10:53:13 | * ... | test.cpp:56:21:56:24 | * ... | AST only |
44+
| test.cpp:53:18:53:21 | (int)... | test.cpp:44:9:44:9 | 0 | AST only |
45+
| test.cpp:53:18:53:21 | (int)... | test.cpp:51:25:51:25 | 0 | AST only |
46+
| test.cpp:53:18:53:21 | (int)... | test.cpp:53:18:53:21 | (int)... | AST only |
47+
| test.cpp:53:18:53:21 | (int)... | test.cpp:56:39:56:42 | (int)... | AST only |
48+
| test.cpp:53:18:53:21 | (int)... | test.cpp:59:17:59:20 | (int)... | AST only |
49+
| test.cpp:53:18:53:21 | (int)... | test.cpp:88:12:88:12 | 0 | AST only |
50+
| test.cpp:55:5:55:7 | ptr | test.cpp:56:47:56:49 | ptr | IR only |
51+
| test.cpp:55:5:55:15 | ... = ... | test.cpp:55:5:55:15 | ... = ... | AST only |
52+
| test.cpp:56:12:56:25 | (...) | test.cpp:56:12:56:25 | (...) | AST only |
53+
| test.cpp:56:12:56:43 | ... && ... | test.cpp:56:12:56:43 | ... && ... | AST only |
54+
| test.cpp:56:13:56:16 | (int)... | test.cpp:56:13:56:16 | (int)... | AST only |
55+
| test.cpp:56:13:56:16 | (int)... | test.cpp:56:31:56:34 | (int)... | AST only |
56+
| test.cpp:56:13:56:16 | (int)... | test.cpp:59:9:59:12 | (int)... | AST only |
57+
| test.cpp:56:13:56:16 | * ... | test.cpp:56:31:56:34 | * ... | AST only |
58+
| test.cpp:56:13:56:16 | * ... | test.cpp:59:9:59:12 | * ... | AST only |
59+
| test.cpp:56:14:56:16 | ptr | test.cpp:56:47:56:49 | ptr | AST only |
60+
| test.cpp:56:14:56:16 | ptr | test.cpp:56:47:56:51 | ... ++ | IR only |
61+
| test.cpp:56:21:56:24 | (int)... | test.cpp:53:10:53:13 | (int)... | AST only |
62+
| test.cpp:56:21:56:24 | (int)... | test.cpp:56:21:56:24 | (int)... | AST only |
63+
| test.cpp:56:21:56:24 | * ... | test.cpp:53:10:53:13 | * ... | AST only |
64+
| test.cpp:56:30:56:43 | (...) | test.cpp:56:30:56:43 | (...) | AST only |
65+
| test.cpp:56:31:56:34 | (int)... | test.cpp:56:13:56:16 | (int)... | AST only |
66+
| test.cpp:56:31:56:34 | (int)... | test.cpp:56:31:56:34 | (int)... | AST only |
67+
| test.cpp:56:31:56:34 | (int)... | test.cpp:59:9:59:12 | (int)... | AST only |
68+
| test.cpp:56:31:56:34 | * ... | test.cpp:56:13:56:16 | * ... | AST only |
69+
| test.cpp:56:31:56:34 | * ... | test.cpp:59:9:59:12 | * ... | AST only |
70+
| test.cpp:56:32:56:34 | ptr | test.cpp:56:47:56:49 | ptr | AST only |
71+
| test.cpp:56:32:56:34 | ptr | test.cpp:56:47:56:51 | ... ++ | IR only |
72+
| test.cpp:56:39:56:42 | (int)... | test.cpp:44:9:44:9 | 0 | AST only |
73+
| test.cpp:56:39:56:42 | (int)... | test.cpp:51:25:51:25 | 0 | AST only |
74+
| test.cpp:56:39:56:42 | (int)... | test.cpp:53:18:53:21 | (int)... | AST only |
75+
| test.cpp:56:39:56:42 | (int)... | test.cpp:56:39:56:42 | (int)... | AST only |
76+
| test.cpp:56:39:56:42 | (int)... | test.cpp:59:17:59:20 | (int)... | AST only |
77+
| test.cpp:56:39:56:42 | (int)... | test.cpp:88:12:88:12 | 0 | AST only |
78+
| test.cpp:56:47:56:49 | ptr | test.cpp:55:5:55:7 | ptr | IR only |
79+
| test.cpp:56:47:56:49 | ptr | test.cpp:56:14:56:16 | ptr | AST only |
80+
| test.cpp:56:47:56:49 | ptr | test.cpp:56:32:56:34 | ptr | AST only |
81+
| test.cpp:56:47:56:49 | ptr | test.cpp:59:10:59:12 | ptr | AST only |
82+
| test.cpp:56:47:56:51 | ... ++ | test.cpp:56:14:56:16 | ptr | IR only |
83+
| test.cpp:56:47:56:51 | ... ++ | test.cpp:56:32:56:34 | ptr | IR only |
84+
| test.cpp:56:47:56:51 | ... ++ | test.cpp:59:10:59:12 | ptr | IR only |
85+
| test.cpp:59:9:59:12 | (int)... | test.cpp:56:13:56:16 | (int)... | AST only |
86+
| test.cpp:59:9:59:12 | (int)... | test.cpp:56:31:56:34 | (int)... | AST only |
87+
| test.cpp:59:9:59:12 | (int)... | test.cpp:59:9:59:12 | (int)... | AST only |
88+
| test.cpp:59:9:59:12 | * ... | test.cpp:56:13:56:16 | * ... | AST only |
89+
| test.cpp:59:9:59:12 | * ... | test.cpp:56:31:56:34 | * ... | AST only |
90+
| test.cpp:59:10:59:12 | ptr | test.cpp:56:47:56:49 | ptr | AST only |
91+
| test.cpp:59:10:59:12 | ptr | test.cpp:56:47:56:51 | ... ++ | IR only |
92+
| test.cpp:59:17:59:20 | (int)... | test.cpp:44:9:44:9 | 0 | AST only |
93+
| test.cpp:59:17:59:20 | (int)... | test.cpp:51:25:51:25 | 0 | AST only |
94+
| test.cpp:59:17:59:20 | (int)... | test.cpp:53:18:53:21 | (int)... | AST only |
95+
| test.cpp:59:17:59:20 | (int)... | test.cpp:56:39:56:42 | (int)... | AST only |
96+
| test.cpp:59:17:59:20 | (int)... | test.cpp:59:17:59:20 | (int)... | AST only |
97+
| test.cpp:59:17:59:20 | (int)... | test.cpp:88:12:88:12 | 0 | AST only |
98+
| test.cpp:62:5:62:10 | result | test.cpp:65:10:65:15 | result | AST only |
99+
| test.cpp:62:5:62:12 | ... ++ | test.cpp:65:10:65:15 | result | IR only |
100+
| test.cpp:65:10:65:15 | result | test.cpp:62:5:62:10 | result | AST only |
101+
| test.cpp:65:10:65:15 | result | test.cpp:62:5:62:12 | ... ++ | IR only |
102+
| test.cpp:77:20:77:28 | call to getAValue | test.cpp:79:7:79:7 | v | IR only |
103+
| test.cpp:77:20:77:30 | (signed short)... | test.cpp:77:20:77:30 | (signed short)... | AST only |
104+
| test.cpp:77:20:77:30 | (signed short)... | test.cpp:79:7:79:7 | v | AST only |
105+
| test.cpp:79:7:79:7 | (int)... | test.cpp:79:7:79:7 | (int)... | AST only |
106+
| test.cpp:79:7:79:7 | v | test.cpp:77:20:77:28 | call to getAValue | IR only |
107+
| test.cpp:79:7:79:7 | v | test.cpp:77:20:77:30 | (signed short)... | AST only |
108+
| test.cpp:79:11:79:20 | (int)... | test.cpp:79:11:79:20 | (int)... | AST only |
109+
| test.cpp:79:24:79:33 | (int)... | test.cpp:79:24:79:33 | (int)... | AST only |
110+
| test.cpp:80:5:80:19 | ... = ... | test.cpp:80:5:80:19 | ... = ... | AST only |
111+
| test.cpp:80:9:80:19 | (signed short)... | test.cpp:80:9:80:19 | (signed short)... | AST only |
112+
| test.cpp:88:3:88:20 | ... = ... | test.cpp:88:3:88:20 | ... = ... | AST only |
113+
| test.cpp:88:12:88:12 | 0 | test.cpp:44:9:44:9 | 0 | AST only |
114+
| test.cpp:88:12:88:12 | 0 | test.cpp:51:25:51:25 | 0 | AST only |
115+
| test.cpp:88:12:88:12 | 0 | test.cpp:53:18:53:21 | (int)... | AST only |
116+
| test.cpp:88:12:88:12 | 0 | test.cpp:56:39:56:42 | (int)... | AST only |
117+
| test.cpp:88:12:88:12 | 0 | test.cpp:59:17:59:20 | (int)... | AST only |
118+
| test.cpp:88:12:88:12 | (void *)... | test.cpp:88:12:88:12 | (void *)... | AST only |
119+
| test.cpp:92:11:92:16 | ... = ... | test.cpp:92:15:92:16 | 10 | IR only |
120+
| test.cpp:92:11:92:16 | ... = ... | test.cpp:93:10:93:10 | x | IR only |
121+
| test.cpp:92:15:92:16 | 10 | test.cpp:92:11:92:16 | ... = ... | IR only |
122+
| test.cpp:92:15:92:16 | 10 | test.cpp:93:10:93:10 | x | IR only |
123+
| test.cpp:93:10:93:10 | x | test.cpp:92:11:92:16 | ... = ... | IR only |
124+
| test.cpp:93:10:93:10 | x | test.cpp:92:15:92:16 | 10 | IR only |
125+
| test.cpp:105:11:105:12 | (Base *)... | test.cpp:105:11:105:12 | (Base *)... | AST only |
126+
| test.cpp:105:11:105:12 | (Base *)... | test.cpp:106:14:106:35 | static_cast<Base *>... | AST only |
127+
| test.cpp:105:11:105:12 | (Base *)... | test.cpp:107:11:107:12 | pb | AST only |
128+
| test.cpp:105:11:105:12 | pd | test.cpp:107:11:107:12 | pb | IR only |
129+
| test.cpp:105:15:105:15 | b | test.cpp:107:15:107:15 | b | AST only |
130+
| test.cpp:105:15:105:15 | b | test.cpp:109:10:109:10 | y | AST only |
131+
| test.cpp:106:14:106:35 | static_cast<Base *>... | test.cpp:105:11:105:12 | (Base *)... | AST only |
132+
| test.cpp:106:14:106:35 | static_cast<Base *>... | test.cpp:106:14:106:35 | static_cast<Base *>... | AST only |
133+
| test.cpp:106:14:106:35 | static_cast<Base *>... | test.cpp:107:11:107:12 | pb | AST only |
134+
| test.cpp:106:33:106:34 | pd | test.cpp:107:11:107:12 | pb | IR only |
135+
| test.cpp:107:11:107:12 | pb | test.cpp:105:11:105:12 | (Base *)... | AST only |
136+
| test.cpp:107:11:107:12 | pb | test.cpp:105:11:105:12 | pd | IR only |
137+
| test.cpp:107:11:107:12 | pb | test.cpp:106:14:106:35 | static_cast<Base *>... | AST only |
138+
| test.cpp:107:11:107:12 | pb | test.cpp:106:33:106:34 | pd | IR only |
139+
| test.cpp:107:15:107:15 | b | test.cpp:105:15:105:15 | b | AST only |
140+
| test.cpp:109:10:109:10 | y | test.cpp:105:15:105:15 | b | AST only |
141+
| test.cpp:113:3:113:5 | a | test.cpp:115:3:115:5 | a | IR only |
142+
| test.cpp:115:3:115:5 | a | test.cpp:113:3:113:5 | a | IR only |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import cpp
2+
import semmle.code.cpp.valuenumbering.GlobalValueNumbering as AST
3+
import semmle.code.cpp.ir.internal.ASTValueNumbering as IR
4+
import semmle.code.cpp.ir.IR
5+
6+
Expr ir(Expr e) { result = IR::globalValueNumber(e).getAnExpr() }
7+
8+
Expr ast(Expr e) { result = AST::globalValueNumber(e).getAnExpr() }
9+
10+
from Expr e, Expr evn, string note
11+
where
12+
evn = ast(e) and not evn = ir(e) and note = "AST only"
13+
or
14+
evn = ir(e) and not evn = ast(e) and note = "IR only"
15+
select e, evn, note

cpp/ql/test/library-tests/valuenumbering/GlobalValueNumbering/ir_uniqueness.expected

Whitespace-only changes.
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.ValueNumbering
3+
import semmle.code.cpp.ir.IR
4+
5+
// Every non-void instruction should have exactly one GVN.
6+
// So this query should have zero results.
7+
from Instruction i
8+
where
9+
not i.getResultIRType() instanceof IRVoidType and
10+
count(valueNumber(i)) != 1
11+
select i, concat(ValueNumber g | g = valueNumber(i) | g.getKind(), ", ")

0 commit comments

Comments
 (0)