Skip to content

Commit e7d8fa4

Browse files
authored
Merge pull request #1945 from geoffw0/more-tests
CPP: Add a test of ConditionalDeclExpr.
2 parents 396a72d + 07e29bb commit e7d8fa4

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
void do_something_with(bool b)
3+
{
4+
// ...
5+
}
6+
7+
void do_something_else_with(int i)
8+
{
9+
// ...
10+
}
11+
12+
void test_if(int x, int y)
13+
{
14+
bool b = x < y;
15+
do_something_with(b);
16+
17+
if (bool c = x < y) { // ConditionalDeclExpr
18+
do_something_with(c);
19+
x++;
20+
}
21+
}
22+
23+
void test_while(int x, int y)
24+
{
25+
while (int d = x - y) { // ConditionalDeclExpr
26+
do_something_else_with(d);
27+
}
28+
}
29+
30+
void test_for(int x, int y)
31+
{
32+
for (int i = 0; bool c = x < y; x++) { // ConditionalDeclExpr
33+
do_something_with(c);
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| conditionaldeclexpr.cpp:17:7:17:20 | (condition decl) | conditionaldeclexpr.cpp:17:12:17:12 | c | conditionaldeclexpr.cpp:17:16:17:20 | ... < ... |
2+
| conditionaldeclexpr.cpp:25:10:25:22 | (condition decl) | conditionaldeclexpr.cpp:25:14:25:14 | d | conditionaldeclexpr.cpp:25:18:25:22 | ... - ... |
3+
| conditionaldeclexpr.cpp:32:19:32:32 | (condition decl) | conditionaldeclexpr.cpp:32:24:32:24 | c | conditionaldeclexpr.cpp:32:28:32:32 | ... < ... |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import cpp
2+
3+
from ConditionDeclExpr cde
4+
select cde, cde.getVariableAccess(), cde.getInitializingExpr()

0 commit comments

Comments
 (0)