mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Merge pull request #1536 from jbj/leap-year-sameBaseType-perf
C++: Fix performance of leap year queries
This commit is contained in:
@@ -53,13 +53,13 @@ predicate setter(MemberVariable v, MemberFunction f, Class c) {
|
|||||||
v.getDeclaringType() = c and
|
v.getDeclaringType() = c and
|
||||||
f.getName().matches("set%") and
|
f.getName().matches("set%") and
|
||||||
v.getAnAssignedValue().getEnclosingFunction() = f and
|
v.getAnAssignedValue().getEnclosingFunction() = f and
|
||||||
not exists(MemberVariable v2 |
|
forall(MemberVariable v2 |
|
||||||
v2.getDeclaringType() = c and
|
v2.getAnAssignedValue().getEnclosingFunction() = f
|
||||||
v2.getAnAssignedValue().getEnclosingFunction() = f and
|
|
|
||||||
v2 != v
|
v2 = v
|
||||||
) and
|
) and
|
||||||
f.getNumberOfParameters() = 1 and
|
f.getNumberOfParameters() = 1 and
|
||||||
sameBaseType(f.getParameter(0).getType(), v.getType())
|
f.getParameter(0).getType().stripType() = v.getType().stripType()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,31 +71,11 @@ predicate getter(MemberVariable v, MemberFunction f, Class c) {
|
|||||||
v.getDeclaringType() = c and
|
v.getDeclaringType() = c and
|
||||||
f.getName().matches("get%") and
|
f.getName().matches("get%") and
|
||||||
v.getAnAccess().getEnclosingFunction() = f and
|
v.getAnAccess().getEnclosingFunction() = f and
|
||||||
not exists(MemberVariable v2 |
|
forall(MemberVariable v2 |
|
||||||
v2.getDeclaringType() = c and
|
v2.getAnAccess().getEnclosingFunction() = f
|
||||||
v2.getAnAccess().getEnclosingFunction() = f and
|
|
|
||||||
v2 != v
|
v2 = v
|
||||||
) and
|
) and
|
||||||
f.getNumberOfParameters() = 0 and
|
f.getNumberOfParameters() = 0 and
|
||||||
sameBaseType(f.getType(), v.getType())
|
f.getType().stripType() = v.getType().stripType()
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds if `t1` and `t2` are the same type up to typedefs, specifiers,
|
|
||||||
* and removing a single layer of pointers or references (but not arrays).
|
|
||||||
* Equates, for example, `const int*` with `int`, but not `int**` with `int`
|
|
||||||
* or `int[]` with `int`.
|
|
||||||
*/
|
|
||||||
predicate sameBaseType(Type t1, Type t2) {
|
|
||||||
exists (Type base1, Type base2 |
|
|
||||||
base1 = t1.getUnspecifiedType() and
|
|
||||||
base2 = t2.getUnspecifiedType().getUnspecifiedType() and
|
|
||||||
(
|
|
||||||
base1 = base2 or
|
|
||||||
base1.(PointerType).getBaseType() = base2 or
|
|
||||||
base2.(PointerType).getBaseType() = base1 or
|
|
||||||
base1.(ReferenceType).getBaseType() = base2 or
|
|
||||||
base2.(ReferenceType).getBaseType() = base1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user