mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Merge pull request #397 from pavgust/fix/suspicious-memset-perf
SuspiciousCallToMemset: Simplify pointer indirection computation
This commit is contained in:
@@ -52,13 +52,13 @@ Type stripType(Type t) {
|
||||
|
||||
/**
|
||||
* Holds if `t` points to `base` via a specified number of levels of pointer
|
||||
* indirection. Intermediate typedefs and array types are allowed.
|
||||
* indirection. Intermediate typedefs and array types are allowed. Note that
|
||||
* `base` is a stripped type (via `stripType`).
|
||||
*/
|
||||
predicate pointerIndirection(Type t, int indirection, Type base) {
|
||||
exists(Type u |
|
||||
u = stripType(t) and
|
||||
u = stripType(base) and
|
||||
not u instanceof PointerType and
|
||||
(
|
||||
base = stripType(t) and
|
||||
not base instanceof PointerType and
|
||||
indirection = 0
|
||||
) or (
|
||||
pointerIndirection(stripType(t).(PointerType).getBaseType(), indirection - 1, base)
|
||||
|
||||
Reference in New Issue
Block a user