Skip to content

Commit f29f0f4

Browse files
committed
Dataflow: Exclude flow param-param flow through with identical params.
1 parent e559009 commit f29f0f4

File tree

19 files changed

+114
-38
lines changed

19 files changed

+114
-38
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20882088

20892089
SummaryCtxSome() { this = TSummaryCtxSome(p, ap) }
20902090

2091+
int getParameterPos() { p.isParameterOf(_, result) }
2092+
20912093
override string toString() { result = p + ": " + ap }
20922094

20932095
predicate hasLocationInfo(
@@ -2481,13 +2483,15 @@ pragma[nomagic]
24812483
private predicate paramFlowsThrough(
24822484
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24832485
) {
2484-
exists(PathNodeMid mid, ReturnNodeExt ret |
2486+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24852487
mid.getNode() = ret and
24862488
kind = ret.getKind() and
24872489
cc = mid.getCallContext() and
24882490
sc = mid.getSummaryCtx() and
24892491
config = mid.getConfiguration() and
2490-
ap = mid.getAp()
2492+
ap = mid.getAp() and
2493+
pos = sc.getParameterPos() and
2494+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24912495
)
24922496
}
24932497

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20882088

20892089
SummaryCtxSome() { this = TSummaryCtxSome(p, ap) }
20902090

2091+
int getParameterPos() { p.isParameterOf(_, result) }
2092+
20912093
override string toString() { result = p + ": " + ap }
20922094

20932095
predicate hasLocationInfo(
@@ -2481,13 +2483,15 @@ pragma[nomagic]
24812483
private predicate paramFlowsThrough(
24822484
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24832485
) {
2484-
exists(PathNodeMid mid, ReturnNodeExt ret |
2486+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24852487
mid.getNode() = ret and
24862488
kind = ret.getKind() and
24872489
cc = mid.getCallContext() and
24882490
sc = mid.getSummaryCtx() and
24892491
config = mid.getConfiguration() and
2490-
ap = mid.getAp()
2492+
ap = mid.getAp() and
2493+
pos = sc.getParameterPos() and
2494+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24912495
)
24922496
}
24932497

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20882088

20892089
SummaryCtxSome() { this = TSummaryCtxSome(p, ap) }
20902090

2091+
int getParameterPos() { p.isParameterOf(_, result) }
2092+
20912093
override string toString() { result = p + ": " + ap }
20922094

20932095
predicate hasLocationInfo(
@@ -2481,13 +2483,15 @@ pragma[nomagic]
24812483
private predicate paramFlowsThrough(
24822484
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24832485
) {
2484-
exists(PathNodeMid mid, ReturnNodeExt ret |
2486+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24852487
mid.getNode() = ret and
24862488
kind = ret.getKind() and
24872489
cc = mid.getCallContext() and
24882490
sc = mid.getSummaryCtx() and
24892491
config = mid.getConfiguration() and
2490-
ap = mid.getAp()
2492+
ap = mid.getAp() and
2493+
pos = sc.getParameterPos() and
2494+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24912495
)
24922496
}
24932497

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20882088

20892089
SummaryCtxSome() { this = TSummaryCtxSome(p, ap) }
20902090

2091+
int getParameterPos() { p.isParameterOf(_, result) }
2092+
20912093
override string toString() { result = p + ": " + ap }
20922094

20932095
predicate hasLocationInfo(
@@ -2481,13 +2483,15 @@ pragma[nomagic]
24812483
private predicate paramFlowsThrough(
24822484
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24832485
) {
2484-
exists(PathNodeMid mid, ReturnNodeExt ret |
2486+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24852487
mid.getNode() = ret and
24862488
kind = ret.getKind() and
24872489
cc = mid.getCallContext() and
24882490
sc = mid.getSummaryCtx() and
24892491
config = mid.getConfiguration() and
2490-
ap = mid.getAp()
2492+
ap = mid.getAp() and
2493+
pos = sc.getParameterPos() and
2494+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24912495
)
24922496
}
24932497

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20882088

20892089
SummaryCtxSome() { this = TSummaryCtxSome(p, ap) }
20902090

2091+
int getParameterPos() { p.isParameterOf(_, result) }
2092+
20912093
override string toString() { result = p + ": " + ap }
20922094

20932095
predicate hasLocationInfo(
@@ -2481,13 +2483,15 @@ pragma[nomagic]
24812483
private predicate paramFlowsThrough(
24822484
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24832485
) {
2484-
exists(PathNodeMid mid, ReturnNodeExt ret |
2486+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24852487
mid.getNode() = ret and
24862488
kind = ret.getKind() and
24872489
cc = mid.getCallContext() and
24882490
sc = mid.getSummaryCtx() and
24892491
config = mid.getConfiguration() and
2490-
ap = mid.getAp()
2492+
ap = mid.getAp() and
2493+
pos = sc.getParameterPos() and
2494+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24912495
)
24922496
}
24932497

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20882088

20892089
SummaryCtxSome() { this = TSummaryCtxSome(p, ap) }
20902090

2091+
int getParameterPos() { p.isParameterOf(_, result) }
2092+
20912093
override string toString() { result = p + ": " + ap }
20922094

20932095
predicate hasLocationInfo(
@@ -2481,13 +2483,15 @@ pragma[nomagic]
24812483
private predicate paramFlowsThrough(
24822484
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24832485
) {
2484-
exists(PathNodeMid mid, ReturnNodeExt ret |
2486+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24852487
mid.getNode() = ret and
24862488
kind = ret.getKind() and
24872489
cc = mid.getCallContext() and
24882490
sc = mid.getSummaryCtx() and
24892491
config = mid.getConfiguration() and
2490-
ap = mid.getAp()
2492+
ap = mid.getAp() and
2493+
pos = sc.getParameterPos() and
2494+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24912495
)
24922496
}
24932497

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20882088

20892089
SummaryCtxSome() { this = TSummaryCtxSome(p, ap) }
20902090

2091+
int getParameterPos() { p.isParameterOf(_, result) }
2092+
20912093
override string toString() { result = p + ": " + ap }
20922094

20932095
predicate hasLocationInfo(
@@ -2481,13 +2483,15 @@ pragma[nomagic]
24812483
private predicate paramFlowsThrough(
24822484
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24832485
) {
2484-
exists(PathNodeMid mid, ReturnNodeExt ret |
2486+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24852487
mid.getNode() = ret and
24862488
kind = ret.getKind() and
24872489
cc = mid.getCallContext() and
24882490
sc = mid.getSummaryCtx() and
24892491
config = mid.getConfiguration() and
2490-
ap = mid.getAp()
2492+
ap = mid.getAp() and
2493+
pos = sc.getParameterPos() and
2494+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24912495
)
24922496
}
24932497

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20882088

20892089
SummaryCtxSome() { this = TSummaryCtxSome(p, ap) }
20902090

2091+
int getParameterPos() { p.isParameterOf(_, result) }
2092+
20912093
override string toString() { result = p + ": " + ap }
20922094

20932095
predicate hasLocationInfo(
@@ -2481,13 +2483,15 @@ pragma[nomagic]
24812483
private predicate paramFlowsThrough(
24822484
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24832485
) {
2484-
exists(PathNodeMid mid, ReturnNodeExt ret |
2486+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24852487
mid.getNode() = ret and
24862488
kind = ret.getKind() and
24872489
cc = mid.getCallContext() and
24882490
sc = mid.getSummaryCtx() and
24892491
config = mid.getConfiguration() and
2490-
ap = mid.getAp()
2492+
ap = mid.getAp() and
2493+
pos = sc.getParameterPos() and
2494+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24912495
)
24922496
}
24932497

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20882088

20892089
SummaryCtxSome() { this = TSummaryCtxSome(p, ap) }
20902090

2091+
int getParameterPos() { p.isParameterOf(_, result) }
2092+
20912093
override string toString() { result = p + ": " + ap }
20922094

20932095
predicate hasLocationInfo(
@@ -2481,13 +2483,15 @@ pragma[nomagic]
24812483
private predicate paramFlowsThrough(
24822484
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24832485
) {
2484-
exists(PathNodeMid mid, ReturnNodeExt ret |
2486+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24852487
mid.getNode() = ret and
24862488
kind = ret.getKind() and
24872489
cc = mid.getCallContext() and
24882490
sc = mid.getSummaryCtx() and
24892491
config = mid.getConfiguration() and
2490-
ap = mid.getAp()
2492+
ap = mid.getAp() and
2493+
pos = sc.getParameterPos() and
2494+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24912495
)
24922496
}
24932497

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20882088

20892089
SummaryCtxSome() { this = TSummaryCtxSome(p, ap) }
20902090

2091+
int getParameterPos() { p.isParameterOf(_, result) }
2092+
20912093
override string toString() { result = p + ": " + ap }
20922094

20932095
predicate hasLocationInfo(
@@ -2481,13 +2483,15 @@ pragma[nomagic]
24812483
private predicate paramFlowsThrough(
24822484
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24832485
) {
2484-
exists(PathNodeMid mid, ReturnNodeExt ret |
2486+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24852487
mid.getNode() = ret and
24862488
kind = ret.getKind() and
24872489
cc = mid.getCallContext() and
24882490
sc = mid.getSummaryCtx() and
24892491
config = mid.getConfiguration() and
2490-
ap = mid.getAp()
2492+
ap = mid.getAp() and
2493+
pos = sc.getParameterPos() and
2494+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24912495
)
24922496
}
24932497

0 commit comments

Comments
 (0)