From d0bd6eb2eb73e9f585ef05423bbedd0d25faa33f Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Thu, 16 Jan 2025 16:55:10 +0000 Subject: [PATCH] C++: Remove the type restriction on 'GuardConditionFromNotExpr' since this class also applies to C++. --- cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll | 1 - .../library-tests/controlflow/guards/GuardsCompare.expected | 4 ++++ .../library-tests/controlflow/guards/GuardsEnsure.expected | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll b/cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll index a88a6c5fc1f..c13f5b5d9cc 100644 --- a/cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll +++ b/cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll @@ -268,7 +268,6 @@ private class GuardConditionFromNotExpr extends GuardConditionImpl { exists(NotExpr notExpr, Type t | this = notExpr.getOperand() and t = this.getUnspecifiedType() and - not t instanceof BoolType and ir.getUnconvertedResultExpression() = notExpr ) } diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected b/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected index dd8fbcadc8b..0963177716c 100644 --- a/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected @@ -262,9 +262,13 @@ | 122 | b == 0 when b is false | | 122 | b == 1 when b is true | | 125 | ! ... != 0 when ! ... is true | +| 125 | ! ... != 0 when call to safe is false | | 125 | ! ... != 1 when ! ... is false | +| 125 | ! ... != 1 when call to safe is true | | 125 | ! ... == 0 when ! ... is false | +| 125 | ! ... == 0 when call to safe is true | | 125 | ! ... == 1 when ! ... is true | +| 125 | ! ... == 1 when call to safe is false | | 125 | call to safe != 0 when ! ... is false | | 125 | call to safe != 0 when call to safe is true | | 125 | call to safe != 1 when ! ... is true | diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected b/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected index cb529666e2c..910438b1f43 100644 --- a/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected @@ -540,6 +540,8 @@ unary | test.cpp:125:13:125:20 | ! ... | test.cpp:125:13:125:20 | ! ... | == | 1 | 125 | 125 | | test.cpp:125:13:125:20 | ! ... | test.cpp:125:14:125:17 | call to safe | != | 1 | 125 | 125 | | test.cpp:125:13:125:20 | ! ... | test.cpp:125:14:125:17 | call to safe | == | 0 | 125 | 125 | +| test.cpp:125:14:125:17 | call to safe | test.cpp:125:13:125:20 | ! ... | != | 0 | 125 | 125 | +| test.cpp:125:14:125:17 | call to safe | test.cpp:125:13:125:20 | ! ... | == | 1 | 125 | 125 | | test.cpp:125:14:125:17 | call to safe | test.cpp:125:14:125:17 | call to safe | != | 1 | 125 | 125 | | test.cpp:125:14:125:17 | call to safe | test.cpp:125:14:125:17 | call to safe | == | 0 | 125 | 125 | | test.cpp:131:6:131:21 | call to __builtin_expect | test.cpp:131:6:131:21 | call to __builtin_expect | != | 0 | 131 | 132 |