Skip to content

Commit 42e180d

Browse files
authored
Merge pull request github#3060 from aschackmull/dataflow/no-param-to-same-param-flow
Dataflow: Exclude param-param flow through with identical params.
2 parents 49f8f24 + f29f0f4 commit 42e180d

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
@@ -2089,6 +2089,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20892089

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

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

20942096
predicate hasLocationInfo(
@@ -2482,13 +2484,15 @@ pragma[nomagic]
24822484
private predicate paramFlowsThrough(
24832485
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24842486
) {
2485-
exists(PathNodeMid mid, ReturnNodeExt ret |
2487+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24862488
mid.getNode() = ret and
24872489
kind = ret.getKind() and
24882490
cc = mid.getCallContext() and
24892491
sc = mid.getSummaryCtx() and
24902492
config = mid.getConfiguration() and
2491-
ap = mid.getAp()
2493+
ap = mid.getAp() and
2494+
pos = sc.getParameterPos() and
2495+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24922496
)
24932497
}
24942498

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

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

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

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

20942096
predicate hasLocationInfo(
@@ -2482,13 +2484,15 @@ pragma[nomagic]
24822484
private predicate paramFlowsThrough(
24832485
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24842486
) {
2485-
exists(PathNodeMid mid, ReturnNodeExt ret |
2487+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24862488
mid.getNode() = ret and
24872489
kind = ret.getKind() and
24882490
cc = mid.getCallContext() and
24892491
sc = mid.getSummaryCtx() and
24902492
config = mid.getConfiguration() and
2491-
ap = mid.getAp()
2493+
ap = mid.getAp() and
2494+
pos = sc.getParameterPos() and
2495+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24922496
)
24932497
}
24942498

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

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

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

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

20942096
predicate hasLocationInfo(
@@ -2482,13 +2484,15 @@ pragma[nomagic]
24822484
private predicate paramFlowsThrough(
24832485
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24842486
) {
2485-
exists(PathNodeMid mid, ReturnNodeExt ret |
2487+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24862488
mid.getNode() = ret and
24872489
kind = ret.getKind() and
24882490
cc = mid.getCallContext() and
24892491
sc = mid.getSummaryCtx() and
24902492
config = mid.getConfiguration() and
2491-
ap = mid.getAp()
2493+
ap = mid.getAp() and
2494+
pos = sc.getParameterPos() and
2495+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24922496
)
24932497
}
24942498

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

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

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

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

20942096
predicate hasLocationInfo(
@@ -2482,13 +2484,15 @@ pragma[nomagic]
24822484
private predicate paramFlowsThrough(
24832485
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24842486
) {
2485-
exists(PathNodeMid mid, ReturnNodeExt ret |
2487+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24862488
mid.getNode() = ret and
24872489
kind = ret.getKind() and
24882490
cc = mid.getCallContext() and
24892491
sc = mid.getSummaryCtx() and
24902492
config = mid.getConfiguration() and
2491-
ap = mid.getAp()
2493+
ap = mid.getAp() and
2494+
pos = sc.getParameterPos() and
2495+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24922496
)
24932497
}
24942498

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

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

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

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

20942096
predicate hasLocationInfo(
@@ -2482,13 +2484,15 @@ pragma[nomagic]
24822484
private predicate paramFlowsThrough(
24832485
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24842486
) {
2485-
exists(PathNodeMid mid, ReturnNodeExt ret |
2487+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24862488
mid.getNode() = ret and
24872489
kind = ret.getKind() and
24882490
cc = mid.getCallContext() and
24892491
sc = mid.getSummaryCtx() and
24902492
config = mid.getConfiguration() and
2491-
ap = mid.getAp()
2493+
ap = mid.getAp() and
2494+
pos = sc.getParameterPos() and
2495+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24922496
)
24932497
}
24942498

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
@@ -2089,6 +2089,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20892089

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

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

20942096
predicate hasLocationInfo(
@@ -2482,13 +2484,15 @@ pragma[nomagic]
24822484
private predicate paramFlowsThrough(
24832485
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24842486
) {
2485-
exists(PathNodeMid mid, ReturnNodeExt ret |
2487+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24862488
mid.getNode() = ret and
24872489
kind = ret.getKind() and
24882490
cc = mid.getCallContext() and
24892491
sc = mid.getSummaryCtx() and
24902492
config = mid.getConfiguration() and
2491-
ap = mid.getAp()
2493+
ap = mid.getAp() and
2494+
pos = sc.getParameterPos() and
2495+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24922496
)
24932497
}
24942498

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
@@ -2089,6 +2089,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20892089

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

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

20942096
predicate hasLocationInfo(
@@ -2482,13 +2484,15 @@ pragma[nomagic]
24822484
private predicate paramFlowsThrough(
24832485
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24842486
) {
2485-
exists(PathNodeMid mid, ReturnNodeExt ret |
2487+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24862488
mid.getNode() = ret and
24872489
kind = ret.getKind() and
24882490
cc = mid.getCallContext() and
24892491
sc = mid.getSummaryCtx() and
24902492
config = mid.getConfiguration() and
2491-
ap = mid.getAp()
2493+
ap = mid.getAp() and
2494+
pos = sc.getParameterPos() and
2495+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24922496
)
24932497
}
24942498

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
@@ -2089,6 +2089,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20892089

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

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

20942096
predicate hasLocationInfo(
@@ -2482,13 +2484,15 @@ pragma[nomagic]
24822484
private predicate paramFlowsThrough(
24832485
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24842486
) {
2485-
exists(PathNodeMid mid, ReturnNodeExt ret |
2487+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24862488
mid.getNode() = ret and
24872489
kind = ret.getKind() and
24882490
cc = mid.getCallContext() and
24892491
sc = mid.getSummaryCtx() and
24902492
config = mid.getConfiguration() and
2491-
ap = mid.getAp()
2493+
ap = mid.getAp() and
2494+
pos = sc.getParameterPos() and
2495+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24922496
)
24932497
}
24942498

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
@@ -2089,6 +2089,8 @@ private class SummaryCtxSome extends SummaryCtx, TSummaryCtxSome {
20892089

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

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

20942096
predicate hasLocationInfo(
@@ -2482,13 +2484,15 @@ pragma[nomagic]
24822484
private predicate paramFlowsThrough(
24832485
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24842486
) {
2485-
exists(PathNodeMid mid, ReturnNodeExt ret |
2487+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24862488
mid.getNode() = ret and
24872489
kind = ret.getKind() and
24882490
cc = mid.getCallContext() and
24892491
sc = mid.getSummaryCtx() and
24902492
config = mid.getConfiguration() and
2491-
ap = mid.getAp()
2493+
ap = mid.getAp() and
2494+
pos = sc.getParameterPos() and
2495+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24922496
)
24932497
}
24942498

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

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

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

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

20942096
predicate hasLocationInfo(
@@ -2482,13 +2484,15 @@ pragma[nomagic]
24822484
private predicate paramFlowsThrough(
24832485
ReturnKindExt kind, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, Configuration config
24842486
) {
2485-
exists(PathNodeMid mid, ReturnNodeExt ret |
2487+
exists(PathNodeMid mid, ReturnNodeExt ret, int pos |
24862488
mid.getNode() = ret and
24872489
kind = ret.getKind() and
24882490
cc = mid.getCallContext() and
24892491
sc = mid.getSummaryCtx() and
24902492
config = mid.getConfiguration() and
2491-
ap = mid.getAp()
2493+
ap = mid.getAp() and
2494+
pos = sc.getParameterPos() and
2495+
not kind.(ParamUpdateReturnKind).getPosition() = pos
24922496
)
24932497
}
24942498

0 commit comments

Comments
 (0)