Skip to content

Commit 36aac3f

Browse files
committed
C++: Get rid of 'relevantUnaryComparison' since it was excluding too much. The performance is most likely fine with that restriction.
1 parent 703832f commit 36aac3f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -856,11 +856,15 @@ private predicate unary_simple_comparison_eq(
856856
inNonZeroCase = false
857857
)
858858
or
859-
// There's no implicit CompareInstruction in files compiled as C since C
860-
// doesn't have implicit boolean conversions. So instead we check whether
861-
// there's a branch on a value of pointer or integer type.
862-
relevantUnaryComparison(test) and
863-
op.getDef() = test and
859+
not test.isGLValue() and
860+
not simple_comparison_eq(test, _, _, _, _) and
861+
not simple_comparison_lt(test, _, _, _) and
862+
not test = any(SwitchInstruction switch).getExpression() and
863+
(
864+
test.getResultIRType() instanceof IRAddressType or
865+
test.getResultIRType() instanceof IRIntegerType or
866+
test.getResultIRType() instanceof IRBooleanType
867+
) and
864868
(
865869
k = 1 and
866870
value.(BooleanValue).getValue() = true and

0 commit comments

Comments
 (0)