mirror of
https://github.com/github/codeql.git
synced 2026-06-19 11:51:08 +02:00
Java: Fix performance issue in type flow library
This commit is contained in:
@@ -72,6 +72,35 @@ module FlowStepsInput implements UniversalFlow::UniversalFlowInput<Location> {
|
||||
}
|
||||
}
|
||||
|
||||
private class FlowNodeElement extends Element {
|
||||
FlowNodeElement() {
|
||||
this instanceof Field or
|
||||
this instanceof Expr or
|
||||
this instanceof Method
|
||||
}
|
||||
}
|
||||
|
||||
private predicate id(FlowNodeElement x, FlowNodeElement y) { x = y }
|
||||
|
||||
private predicate idOf(FlowNodeElement x, int y) = equivalenceRelation(id/2)(x, y)
|
||||
|
||||
int getFlowNodeId(FlowNode n) {
|
||||
n =
|
||||
rank[result](FlowNode n0, int a, int b |
|
||||
a = 0 and
|
||||
idOf(any(n0.asField()), b)
|
||||
or
|
||||
// no case for `n0.asSsa()`; here we rely on the built-in location-based ranking
|
||||
a = 1 and
|
||||
idOf(any(n0.asExpr()), b)
|
||||
or
|
||||
a = 2 and
|
||||
idOf(any(n0.asMethod()), b)
|
||||
|
|
||||
n0 order by a, b
|
||||
)
|
||||
}
|
||||
|
||||
private SrcCallable viableCallable_v1(Call c) {
|
||||
result = viableImpl_v1(c)
|
||||
or
|
||||
@@ -165,6 +194,8 @@ private module Input implements TypeFlowInput<Location> {
|
||||
|
||||
class TypeFlowNode = FlowNode;
|
||||
|
||||
predicate getTypeFlowNodeId = FlowStepsInput::getFlowNodeId/1;
|
||||
|
||||
predicate isExcludedFromNullAnalysis = FlowStepsInput::isExcludedFromNullAnalysis/1;
|
||||
|
||||
class Type = RefType;
|
||||
|
||||
@@ -170,6 +170,8 @@ private class EmptyCollectionConstructor extends Constructor {
|
||||
private module CollectionFlowStepsInput implements UniversalFlow::UniversalFlowInput<Location> {
|
||||
import FlowStepsInput
|
||||
|
||||
predicate getFlowNodeId = FlowStepsInput::getFlowNodeId/1;
|
||||
|
||||
/**
|
||||
* Holds if `n2` is a collection/array/constant whose value(s) are
|
||||
* determined completely from the range of `n1` nodes.
|
||||
|
||||
Reference in New Issue
Block a user