mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
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.
This commit is contained in:
@@ -48,26 +48,27 @@ predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr
|
||||
// it is being used in an equality or logical operation
|
||||
exists(EqualityOperation eop |
|
||||
eop = expr1 and
|
||||
func = eop.getAChild()
|
||||
func = eop.getAnOperand()
|
||||
)
|
||||
or
|
||||
exists(UnaryLogicalOperation ule |
|
||||
expr1 = ule and
|
||||
func = ule.getAChild()
|
||||
func = ule.getOperand()
|
||||
)
|
||||
or
|
||||
exists(BinaryLogicalOperation ble |
|
||||
expr1 = ble and
|
||||
func = ble.getAChild()
|
||||
func = ble.getAnOperand()
|
||||
)
|
||||
) and
|
||||
msg = "Return value of " + func.getTarget().getQualifiedName() +
|
||||
" used in a logical operation."
|
||||
)
|
||||
or
|
||||
exists(ConditionalStmt condstmt | condstmt.getAChild() = expr1 |
|
||||
exists(ConditionalStmt condstmt |
|
||||
// or the string copy function is used directly as the conditional expression
|
||||
func = condstmt.getChild(0) and
|
||||
func = condstmt.getControllingExpr() and
|
||||
expr1 = func and
|
||||
msg = "Return value of " + func.getTarget().getQualifiedName() +
|
||||
" used directly in a conditional expression."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user