Skip to content

Commit 32a738b

Browse files
committed
Dataflow: Add type to PathNode.toString.
1 parent 8fcfc6f commit 32a738b

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,6 +3031,17 @@ module Impl<FullStateConfigSig Config> {
30313031
this instanceof PathNodeSinkGroup
30323032
}
30333033

3034+
private string ppType() {
3035+
this instanceof PathNodeSink and result = ""
3036+
or
3037+
this.(PathNodeMid).getAp() instanceof AccessPathNil and result = ""
3038+
or
3039+
exists(DataFlowType t | t = this.(PathNodeMid).getAp().getHead().getContainerType() |
3040+
// The `concat` becomes "" if `ppReprType` has no result.
3041+
result = concat(" : " + ppReprType(t))
3042+
)
3043+
}
3044+
30343045
private string ppAp() {
30353046
this instanceof PathNodeSink and result = ""
30363047
or
@@ -3046,14 +3057,14 @@ module Impl<FullStateConfigSig Config> {
30463057
}
30473058

30483059
/** Gets a textual representation of this element. */
3049-
string toString() { result = this.getNodeEx().toString() + this.ppAp() }
3060+
string toString() { result = this.getNodeEx().toString() + this.ppType() + this.ppAp() }
30503061

30513062
/**
30523063
* Gets a textual representation of this element, including a textual
30533064
* representation of the call context.
30543065
*/
30553066
string toStringWithContext() {
3056-
result = this.getNodeEx().toString() + this.ppAp() + this.ppCtx()
3067+
result = this.getNodeEx().toString() + this.ppType() + this.ppAp() + this.ppCtx()
30573068
}
30583069

30593070
/**
@@ -3998,14 +4009,14 @@ module Impl<FullStateConfigSig Config> {
39984009
*/
39994010
class PartialPathNode extends TPartialPathNode {
40004011
/** Gets a textual representation of this element. */
4001-
string toString() { result = this.getNodeEx().toString() + this.ppAp() }
4012+
string toString() { result = this.getNodeEx().toString() + this.ppType() + this.ppAp() }
40024013

40034014
/**
40044015
* Gets a textual representation of this element, including a textual
40054016
* representation of the call context.
40064017
*/
40074018
string toStringWithContext() {
4008-
result = this.getNodeEx().toString() + this.ppAp() + this.ppCtx()
4019+
result = this.getNodeEx().toString() + this.ppType() + this.ppAp() + this.ppCtx()
40094020
}
40104021

40114022
/**
@@ -4046,6 +4057,19 @@ module Impl<FullStateConfigSig Config> {
40464057
*/
40474058
int getSinkDistance() { result = distSink(this.getNodeEx().getEnclosingCallable()) }
40484059

4060+
private string ppType() {
4061+
this instanceof PartialPathNodeRev and result = ""
4062+
or
4063+
this.(PartialPathNodeFwd).getAp() instanceof PartialAccessPathNil and result = ""
4064+
or
4065+
exists(DataFlowType t |
4066+
t = this.(PartialPathNodeFwd).getAp().(PartialAccessPathCons).getType()
4067+
|
4068+
// The `concat` becomes "" if `ppReprType` has no result.
4069+
result = concat(" : " + ppReprType(t))
4070+
)
4071+
}
4072+
40494073
private string ppAp() {
40504074
exists(string s |
40514075
s = this.(PartialPathNodeFwd).getAp().toString() or

0 commit comments

Comments
 (0)