Skip to content

Commit 36043d0

Browse files
authored
Merge pull request github#1729 from xiemaisi/data-flow-nodes-___location
Java/C++/C#: Provide path-node locations via `hasLocationInfo`, not `getLocation`.
2 parents e241373 + 485d426 commit 36043d0

File tree

23 files changed

+269
-37
lines changed

23 files changed

+269
-37
lines changed

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode {
14471447
*/
14481448
string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() }
14491449

1450-
/** Gets the source ___location for this element. */
1451-
DataFlowLocation getLocation() { result = getNode().getLocation() }
1450+
/**
1451+
* Holds if this element is at the specified ___location.
1452+
* The ___location spans column `startcolumn` of line `startline` to
1453+
* column `endcolumn` of line `endline` in file `filepath`.
1454+
* For more information, see
1455+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
1456+
*/
1457+
predicate hasLocationInfo(
1458+
string filepath, int startline, int startcolumn, int endline, int endcolumn
1459+
) {
1460+
getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
1461+
}
14521462

14531463
/** Gets the underlying `Node`. */
14541464
abstract Node getNode();

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode {
14471447
*/
14481448
string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() }
14491449

1450-
/** Gets the source ___location for this element. */
1451-
DataFlowLocation getLocation() { result = getNode().getLocation() }
1450+
/**
1451+
* Holds if this element is at the specified ___location.
1452+
* The ___location spans column `startcolumn` of line `startline` to
1453+
* column `endcolumn` of line `endline` in file `filepath`.
1454+
* For more information, see
1455+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
1456+
*/
1457+
predicate hasLocationInfo(
1458+
string filepath, int startline, int startcolumn, int endline, int endcolumn
1459+
) {
1460+
getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
1461+
}
14521462

14531463
/** Gets the underlying `Node`. */
14541464
abstract Node getNode();

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode {
14471447
*/
14481448
string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() }
14491449

1450-
/** Gets the source ___location for this element. */
1451-
DataFlowLocation getLocation() { result = getNode().getLocation() }
1450+
/**
1451+
* Holds if this element is at the specified ___location.
1452+
* The ___location spans column `startcolumn` of line `startline` to
1453+
* column `endcolumn` of line `endline` in file `filepath`.
1454+
* For more information, see
1455+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
1456+
*/
1457+
predicate hasLocationInfo(
1458+
string filepath, int startline, int startcolumn, int endline, int endcolumn
1459+
) {
1460+
getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
1461+
}
14521462

14531463
/** Gets the underlying `Node`. */
14541464
abstract Node getNode();

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode {
14471447
*/
14481448
string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() }
14491449

1450-
/** Gets the source ___location for this element. */
1451-
DataFlowLocation getLocation() { result = getNode().getLocation() }
1450+
/**
1451+
* Holds if this element is at the specified ___location.
1452+
* The ___location spans column `startcolumn` of line `startline` to
1453+
* column `endcolumn` of line `endline` in file `filepath`.
1454+
* For more information, see
1455+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
1456+
*/
1457+
predicate hasLocationInfo(
1458+
string filepath, int startline, int startcolumn, int endline, int endcolumn
1459+
) {
1460+
getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
1461+
}
14521462

14531463
/** Gets the underlying `Node`. */
14541464
abstract Node getNode();

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ class Node extends TNode {
5555
/** Gets the ___location of this element. */
5656
Location getLocation() { none() } // overridden by subclasses
5757

58+
/**
59+
* Holds if this element is at the specified ___location.
60+
* The ___location spans column `startcolumn` of line `startline` to
61+
* column `endcolumn` of line `endline` in file `filepath`.
62+
* For more information, see
63+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
64+
*/
65+
predicate hasLocationInfo(
66+
string filepath, int startline, int startcolumn, int endline, int endcolumn
67+
) {
68+
getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
69+
}
70+
5871
/**
5972
* Gets an upper bound on the type of this node.
6073
*/

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode {
14471447
*/
14481448
string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() }
14491449

1450-
/** Gets the source ___location for this element. */
1451-
DataFlowLocation getLocation() { result = getNode().getLocation() }
1450+
/**
1451+
* Holds if this element is at the specified ___location.
1452+
* The ___location spans column `startcolumn` of line `startline` to
1453+
* column `endcolumn` of line `endline` in file `filepath`.
1454+
* For more information, see
1455+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
1456+
*/
1457+
predicate hasLocationInfo(
1458+
string filepath, int startline, int startcolumn, int endline, int endcolumn
1459+
) {
1460+
getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
1461+
}
14521462

14531463
/** Gets the underlying `Node`. */
14541464
abstract Node getNode();

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode {
14471447
*/
14481448
string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() }
14491449

1450-
/** Gets the source ___location for this element. */
1451-
DataFlowLocation getLocation() { result = getNode().getLocation() }
1450+
/**
1451+
* Holds if this element is at the specified ___location.
1452+
* The ___location spans column `startcolumn` of line `startline` to
1453+
* column `endcolumn` of line `endline` in file `filepath`.
1454+
* For more information, see
1455+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
1456+
*/
1457+
predicate hasLocationInfo(
1458+
string filepath, int startline, int startcolumn, int endline, int endcolumn
1459+
) {
1460+
getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
1461+
}
14521462

14531463
/** Gets the underlying `Node`. */
14541464
abstract Node getNode();

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode {
14471447
*/
14481448
string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() }
14491449

1450-
/** Gets the source ___location for this element. */
1451-
DataFlowLocation getLocation() { result = getNode().getLocation() }
1450+
/**
1451+
* Holds if this element is at the specified ___location.
1452+
* The ___location spans column `startcolumn` of line `startline` to
1453+
* column `endcolumn` of line `endline` in file `filepath`.
1454+
* For more information, see
1455+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
1456+
*/
1457+
predicate hasLocationInfo(
1458+
string filepath, int startline, int startcolumn, int endline, int endcolumn
1459+
) {
1460+
getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
1461+
}
14521462

14531463
/** Gets the underlying `Node`. */
14541464
abstract Node getNode();

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,18 @@ abstract class PathNode extends TPathNode {
14471447
*/
14481448
string toStringWithContext() { result = getNode().toString() + ppAp() + ppCtx() }
14491449

1450-
/** Gets the source ___location for this element. */
1451-
DataFlowLocation getLocation() { result = getNode().getLocation() }
1450+
/**
1451+
* Holds if this element is at the specified ___location.
1452+
* The ___location spans column `startcolumn` of line `startline` to
1453+
* column `endcolumn` of line `endline` in file `filepath`.
1454+
* For more information, see
1455+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
1456+
*/
1457+
predicate hasLocationInfo(
1458+
string filepath, int startline, int startcolumn, int endline, int endcolumn
1459+
) {
1460+
getNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
1461+
}
14521462

14531463
/** Gets the underlying `Node`. */
14541464
abstract Node getNode();

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ class Node extends Instruction {
5151
* Gets an upper bound on the type of this node.
5252
*/
5353
Type getTypeBound() { result = getType() }
54+
55+
/**
56+
* Holds if this element is at the specified ___location.
57+
* The ___location spans column `startcolumn` of line `startline` to
58+
* column `endcolumn` of line `endline` in file `filepath`.
59+
* For more information, see
60+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
61+
*/
62+
predicate hasLocationInfo(
63+
string filepath, int startline, int startcolumn, int endline, int endcolumn
64+
) {
65+
getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
66+
}
5467
}
5568

5669
/**

0 commit comments

Comments
 (0)