From eb8087f4eae25b5786210e663184dd5575fd4b92 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Mon, 12 Aug 2019 12:52:30 +0100 Subject: [PATCH] Java/C++/C#: Provide path-node locations via `hasLocationInfo`, not `getLocation`. --- .../code/cpp/dataflow/internal/DataFlowImpl.qll | 14 ++++++++++++-- .../code/cpp/dataflow/internal/DataFlowImpl2.qll | 14 ++++++++++++-- .../code/cpp/dataflow/internal/DataFlowImpl3.qll | 14 ++++++++++++-- .../code/cpp/dataflow/internal/DataFlowImpl4.qll | 14 ++++++++++++-- .../code/cpp/dataflow/internal/DataFlowUtil.qll | 13 +++++++++++++ .../code/cpp/ir/dataflow/internal/DataFlowImpl.qll | 14 ++++++++++++-- .../cpp/ir/dataflow/internal/DataFlowImpl2.qll | 14 ++++++++++++-- .../cpp/ir/dataflow/internal/DataFlowImpl3.qll | 14 ++++++++++++-- .../cpp/ir/dataflow/internal/DataFlowImpl4.qll | 14 ++++++++++++-- .../code/cpp/ir/dataflow/internal/DataFlowUtil.qll | 13 +++++++++++++ .../code/csharp/dataflow/internal/DataFlowImpl.qll | 14 ++++++++++++-- .../csharp/dataflow/internal/DataFlowImpl2.qll | 14 ++++++++++++-- .../csharp/dataflow/internal/DataFlowImpl3.qll | 14 ++++++++++++-- .../csharp/dataflow/internal/DataFlowImpl4.qll | 14 ++++++++++++-- .../csharp/dataflow/internal/DataFlowImpl5.qll | 14 ++++++++++++-- .../csharp/dataflow/internal/DataFlowPublic.qll | 13 +++++++++++++ .../code/java/dataflow/internal/DataFlowImpl.qll | 14 ++++++++++++-- .../code/java/dataflow/internal/DataFlowImpl2.qll | 14 ++++++++++++-- .../code/java/dataflow/internal/DataFlowImpl3.qll | 14 ++++++++++++-- .../code/java/dataflow/internal/DataFlowImpl4.qll | 14 ++++++++++++-- .../code/java/dataflow/internal/DataFlowImpl5.qll | 14 ++++++++++++-- .../code/java/dataflow/internal/DataFlowUtil.qll | 13 +++++++++++++ 22 files changed, 268 insertions(+), 36 deletions(-) diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll index 49686124c78..1d51a88d13d 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll index 49686124c78..1d51a88d13d 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll index 49686124c78..1d51a88d13d 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll index 49686124c78..1d51a88d13d 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll index 56f8727d213..e9b82a54e43 100644 --- a/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll +++ b/cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll @@ -55,6 +55,19 @@ class Node extends TNode { /** Gets the location of this element. */ Location getLocation() { none() } // overridden by subclasses + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } + /** * Gets an upper bound on the type of this node. */ diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll index 49686124c78..1d51a88d13d 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll index 49686124c78..1d51a88d13d 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll index 49686124c78..1d51a88d13d 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll index 49686124c78..1d51a88d13d 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll index 78fd0fd6133..d2101d09ab4 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll @@ -51,6 +51,19 @@ class Node extends Instruction { * Gets an upper bound on the type of this node. */ Type getTypeBound() { result = 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } } /** diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll index 49686124c78..1d51a88d13d 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll index 49686124c78..1d51a88d13d 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll index 49686124c78..1d51a88d13d 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll index 49686124c78..1d51a88d13d 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll index 49686124c78..1d51a88d13d 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowPublic.qll b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowPublic.qll index 32ce3dca4ac..13fcb586395 100644 --- a/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowPublic.qll +++ b/csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowPublic.qll @@ -46,6 +46,19 @@ class Node extends TNode { /** Gets the location of this node. */ cached Location getLocation() { none() } + + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } } /** diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll index 49686124c78..1d51a88d13d 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll index 49686124c78..1d51a88d13d 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll index 49686124c78..1d51a88d13d 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll index 49686124c78..1d51a88d13d 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl4.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll index 49686124c78..1d51a88d13d 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl5.qll @@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode { */ string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() } - /** Gets the source location for this element. */ - DataFlowLocation getLocation() { result = getNode().getLocation() } + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } /** Gets the underlying `Node`. */ abstract Node getNode(); diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowUtil.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowUtil.qll index 7fab84a10e2..aae6f2ae2df 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowUtil.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowUtil.qll @@ -90,6 +90,19 @@ class Node extends TNode { or result = getType() and not exists(getImprovedTypeBound()) } + + /** + * 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://help.semmle.com/QL/learn-ql/ql/locations.html). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) + } } /**