Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aafb4ab

Browse files
committed
C++: Use more specific predicates than getChild
This commit doesn't change any behavior but just uses the preferred high-level predicates. The `getChild` predicate inspects the raw database more or less directly, and the database layout could change in the future.
1 parent 657fe0e commit aafb4ab

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,27 @@ predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr
4848
// it is being used in an equality or logical operation
4949
exists(EqualityOperation eop |
5050
eop = expr1 and
51-
func = eop.getAChild()
51+
func = eop.getAnOperand()
5252
)
5353
or
5454
exists(UnaryLogicalOperation ule |
5555
expr1 = ule and
56-
func = ule.getAChild()
56+
func = ule.getOperand()
5757
)
5858
or
5959
exists(BinaryLogicalOperation ble |
6060
expr1 = ble and
61-
func = ble.getAChild()
61+
func = ble.getAnOperand()
6262
)
6363
) and
6464
msg = "Return value of " + func.getTarget().getQualifiedName() +
6565
" used in a logical operation."
6666
)
6767
or
68-
exists(ConditionalStmt condstmt | condstmt.getAChild() = expr1 |
68+
exists(ConditionalStmt condstmt |
6969
// or the string copy function is used directly as the conditional expression
70-
func = condstmt.getChild(0) and
70+
func = condstmt.getControllingExpr() and
71+
expr1 = func and
7172
msg = "Return value of " + func.getTarget().getQualifiedName() +
7273
" used directly in a conditional expression."
7374
)

0 commit comments

Comments
 (0)