Java/Shared: Use getLocation instead of hasLocationInfo.

This commit is contained in:
Mathias Vorreiter Pedersen
2024-03-20 14:29:48 +00:00
parent 2fd57f6ee7
commit 90fbacc7bf
3 changed files with 13 additions and 24 deletions

View File

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