Merge pull request #397 from pavgust/fix/suspicious-memset-perf

SuspiciousCallToMemset: Simplify pointer indirection computation
This commit is contained in:
Geoffrey White
2018-11-01 18:46:30 +00:00
committed by GitHub

View File

@@ -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)