mirror of
https://github.com/github/codeql.git
synced 2025-12-19 18:33:16 +01:00
CPP: Optimize isRandValue.
This commit is contained in:
@@ -16,12 +16,19 @@ import semmle.code.cpp.security.Overflow
|
||||
import semmle.code.cpp.security.Security
|
||||
import semmle.code.cpp.security.TaintTracking
|
||||
|
||||
predicate isRandCall(FunctionCall fc) { fc.getTarget().getName() = "rand" }
|
||||
|
||||
predicate isRandCallOrParent(Expr e) {
|
||||
isRandCall(e) or
|
||||
isRandCallOrParent(e.getAChild())
|
||||
}
|
||||
|
||||
predicate isRandValue(Expr e) {
|
||||
e.(FunctionCall).getTarget().getName() = "rand"
|
||||
isRandCall(e)
|
||||
or
|
||||
exists(MacroInvocation mi |
|
||||
e = mi.getExpr() and
|
||||
e.getAChild*().(FunctionCall).getTarget().getName() = "rand"
|
||||
isRandCallOrParent(e)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user