mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
Merge pull request #1945 from geoffw0/more-tests
CPP: Add a test of ConditionalDeclExpr.
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
void do_something_with(bool b)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_something_else_with(int i)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_if(int x, int y)
|
||||||
|
{
|
||||||
|
bool b = x < y;
|
||||||
|
do_something_with(b);
|
||||||
|
|
||||||
|
if (bool c = x < y) { // ConditionalDeclExpr
|
||||||
|
do_something_with(c);
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_while(int x, int y)
|
||||||
|
{
|
||||||
|
while (int d = x - y) { // ConditionalDeclExpr
|
||||||
|
do_something_else_with(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_for(int x, int y)
|
||||||
|
{
|
||||||
|
for (int i = 0; bool c = x < y; x++) { // ConditionalDeclExpr
|
||||||
|
do_something_with(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
| conditionaldeclexpr.cpp:17:7:17:20 | (condition decl) | conditionaldeclexpr.cpp:17:12:17:12 | c | conditionaldeclexpr.cpp:17:16:17:20 | ... < ... |
|
||||||
|
| conditionaldeclexpr.cpp:25:10:25:22 | (condition decl) | conditionaldeclexpr.cpp:25:14:25:14 | d | conditionaldeclexpr.cpp:25:18:25:22 | ... - ... |
|
||||||
|
| conditionaldeclexpr.cpp:32:19:32:32 | (condition decl) | conditionaldeclexpr.cpp:32:24:32:24 | c | conditionaldeclexpr.cpp:32:28:32:32 | ... < ... |
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import cpp
|
||||||
|
|
||||||
|
from ConditionDeclExpr cde
|
||||||
|
select cde, cde.getVariableAccess(), cde.getInitializingExpr()
|
||||||
Reference in New Issue
Block a user