Skip to content

Commit 4dafa16

Browse files
committed
C++: Fix FP on unevaluated code
This fixes false positives on tenzir/vast.
1 parent a1af96e commit 4dafa16

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

cpp/ql/src/Likely Bugs/Likely Typos/CompareWhereAssignMeant.ql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import cpp
1515

1616
from ExprInVoidContext op
1717
where
18-
op instanceof EQExpr
19-
or
20-
op.(FunctionCall).getTarget().hasName("operator==")
18+
not op.isUnevaluated() and
19+
(
20+
op instanceof EQExpr
21+
or
22+
op.(FunctionCall).getTarget().hasName("operator==")
23+
)
2124
select op, "This '==' operator has no effect. The assignment ('=') operator was probably intended."

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/CompareWhereAssignMeant/CompareWhereAssignMeant.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@
66
| test.cpp:39:23:39:28 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
77
| test.cpp:42:23:42:28 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
88
| test.cpp:51:13:51:13 | call to operator== | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
9-
| test.cpp:61:44:61:51 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/CompareWhereAssignMeant/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ void f(void) {
5858
// This pattern is used to emulate C++20 concepts in a way that's very light on
5959
// template syntax.
6060
template<typename T1, typename T2>
61-
auto sfinaeTrick(T1 x1, T2 x2) -> decltype(x1 == x2, bool()) { // GOOD [FALSE POSITIVE]
61+
auto sfinaeTrick(T1 x1, T2 x2) -> decltype(x1 == x2, bool()) { // GOOD
6262
return x1 == x2;
6363
}

0 commit comments

Comments
 (0)