Skip to content

Commit e9bde9b

Browse files
committed
C++: Work around issue with ConditionalDeclExpr.
1 parent 79bda00 commit e9bde9b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cpp/ql/src/Best Practices/Unused Entities/UnusedLocals.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@ where
6161
not exists(Literal l |
6262
l.getEnclosingFunction() = f and
6363
not exists(l.getValue())
64-
)
64+
) and
65+
not any(ConditionDeclExpr cde).getEnclosingFunction() = f
6566
select v, "Variable " + v.getName() + " is not used"

cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedLocals/UnusedLocals.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
| code2.cpp:64:7:64:8 | v3 | Variable v3 is not used |
88
| code2.cpp:108:11:108:12 | v2 | Variable v2 is not used |
99
| code2.cpp:128:9:128:9 | b | Variable b is not used |
10-
| code2.cpp:141:18:141:18 | b | Variable b is not used |
1110
| code.c:10:18:10:18 | y | Variable y is not used |
1211
| code.c:11:18:11:18 | z | Variable z is not used |
1312
| code.c:18:7:18:7 | x | Variable x is not used |

cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedLocals/code2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ int test_lambdas2()
138138

139139
void test_if_initializer()
140140
{
141-
bool a = false, b = true; // GOOD: a, b are both used [FALSE POSITIVE]
141+
bool a = false, b = true; // GOOD: a, b are both used
142142

143143
if (a = b; a)
144144
{

0 commit comments

Comments
 (0)