mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
Java/Shared: Use getLocation instead of hasLocationInfo.
This commit is contained in:
@@ -14,7 +14,7 @@ private import semmle.code.java.dataflow.internal.BaseSSA
|
||||
private import semmle.code.java.controlflow.Guards
|
||||
private import codeql.typeflow.TypeFlow
|
||||
|
||||
private module Input implements TypeFlowInput {
|
||||
private module Input implements TypeFlowInput<J::Location> {
|
||||
private newtype TTypeFlowNode =
|
||||
TField(Field f) { not f.getType() instanceof PrimitiveType } or
|
||||
TSsa(BaseSsaVariable ssa) { not ssa.getSourceVariable().getType() instanceof PrimitiveType } or
|
||||
@@ -38,12 +38,6 @@ private module Input implements TypeFlowInput {
|
||||
result = this.asMethod().toString()
|
||||
}
|
||||
|
||||
predicate hasLocationInfo(
|
||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||
) {
|
||||
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
}
|
||||
|
||||
Location getLocation() {
|
||||
result = this.asField().getLocation() or
|
||||
result = this.asSsa().getLocation() or
|
||||
@@ -164,7 +158,7 @@ private module Input implements TypeFlowInput {
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private predicate upcastCand(TypeFlowNode n, RefType t1, RefType t1e, RefType t2, RefType t2e) {
|
||||
exists(TypeFlowNode next | step(n, next) or Make<Input>::joinStep(n, next) |
|
||||
exists(TypeFlowNode next | step(n, next) or Make<J::Location, Input>::joinStep(n, next) |
|
||||
n.getType() = t1 and
|
||||
next.getType() = t2 and
|
||||
t1.getErasure() = t1e and
|
||||
@@ -356,7 +350,7 @@ private module Input implements TypeFlowInput {
|
||||
|
||||
cached
|
||||
private module TypeFlowBounds {
|
||||
private module TypeFlow = Make<Input>;
|
||||
private module TypeFlow = Make<J::Location, Input>;
|
||||
|
||||
/**
|
||||
* Holds if the runtime type of `f` is bounded by `t` and if this bound is
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
* explicit or implicit cast that lost type information.
|
||||
*/
|
||||
|
||||
private import codeql.util.Location
|
||||
|
||||
/** Provides the input specification. */
|
||||
signature module TypeFlowInput {
|
||||
signature module TypeFlowInput<LocationSig Location> {
|
||||
/**
|
||||
* A node for which type information is available. For example, expressions
|
||||
* and method declarations.
|
||||
@@ -21,16 +23,8 @@ signature module TypeFlowInput {
|
||||
/** Gets the type of this node. */
|
||||
Type getType();
|
||||
|
||||
/**
|
||||
* Holds if this element is at the specified location.
|
||||
* The location spans column `startcolumn` of line `startline` to
|
||||
* column `endcolumn` of line `endline` in file `filepath`.
|
||||
* For more information, see
|
||||
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
|
||||
*/
|
||||
predicate hasLocationInfo(
|
||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||
);
|
||||
/** Gets the location of this node. */
|
||||
Location getLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,6 +106,6 @@ private import internal.TypeFlowImpl as Impl
|
||||
/**
|
||||
* Provides an implementation of type-flow using input `I`.
|
||||
*/
|
||||
module Make<TypeFlowInput I> {
|
||||
import Impl::TypeFlow<I>
|
||||
module Make<LocationSig Location, TypeFlowInput<Location> I> {
|
||||
import Impl::TypeFlow<Location, I>
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
private import codeql.typeflow.TypeFlow
|
||||
private import codeql.util.Location
|
||||
private import codeql.util.Unit
|
||||
|
||||
module TypeFlow<TypeFlowInput I> {
|
||||
module TypeFlow<LocationSig Location, TypeFlowInput<Location> I> {
|
||||
private import I
|
||||
|
||||
/**
|
||||
@@ -56,7 +57,7 @@ module TypeFlow<TypeFlowInput I> {
|
||||
n1 =
|
||||
rank[r](TypeFlowNode n, int startline, int startcolumn |
|
||||
edge(n, n2) and
|
||||
n.hasLocationInfo(_, startline, startcolumn, _, _)
|
||||
n.getLocation().hasLocationInfo(_, startline, startcolumn, _, _)
|
||||
|
|
||||
n order by startline, startcolumn
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user