Skip to content

Commit 282b5d4

Browse files
authored
Merge pull request github#12538 from michaelnebel/emptypredworkaround
DataFlow: Workaround empty predicate usage in IPA branch.
2 parents d264785 + 3fea9e4 commit 282b5d4

File tree

8 files changed

+48
-80
lines changed

8 files changed

+48
-80
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ module Impl<FullStateConfigSig Config> {
418418
)
419419
}
420420

421+
private predicate sourceCallCtx(CallContext cc) {
422+
if hasSourceCallCtx() then cc instanceof CallContextSomeCall else cc instanceof CallContextAny
423+
}
424+
421425
private predicate hasSinkCallCtx() {
422426
exists(FlowFeature feature | feature = Config::getAFeature() |
423427
feature instanceof FeatureHasSinkCallContext or
@@ -2804,11 +2808,7 @@ module Impl<FullStateConfigSig Config> {
28042808
// A PathNode is introduced by a source ...
28052809
Stage5::revFlow(node, state) and
28062810
sourceNode(node, state) and
2807-
(
2808-
if hasSourceCallCtx()
2809-
then cc instanceof CallContextSomeCall
2810-
else cc instanceof CallContextAny
2811-
) and
2811+
sourceCallCtx(cc) and
28122812
sc instanceof SummaryCtxNone and
28132813
ap = TAccessPathNil(node.getDataFlowType())
28142814
or
@@ -3214,11 +3214,7 @@ module Impl<FullStateConfigSig Config> {
32143214

32153215
override predicate isSource() {
32163216
sourceNode(node, state) and
3217-
(
3218-
if hasSourceCallCtx()
3219-
then cc instanceof CallContextSomeCall
3220-
else cc instanceof CallContextAny
3221-
) and
3217+
sourceCallCtx(cc) and
32223218
sc instanceof SummaryCtxNone and
32233219
ap = TAccessPathNil(node.getDataFlowType())
32243220
}

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ module Impl<FullStateConfigSig Config> {
418418
)
419419
}
420420

421+
private predicate sourceCallCtx(CallContext cc) {
422+
if hasSourceCallCtx() then cc instanceof CallContextSomeCall else cc instanceof CallContextAny
423+
}
424+
421425
private predicate hasSinkCallCtx() {
422426
exists(FlowFeature feature | feature = Config::getAFeature() |
423427
feature instanceof FeatureHasSinkCallContext or
@@ -2804,11 +2808,7 @@ module Impl<FullStateConfigSig Config> {
28042808
// A PathNode is introduced by a source ...
28052809
Stage5::revFlow(node, state) and
28062810
sourceNode(node, state) and
2807-
(
2808-
if hasSourceCallCtx()
2809-
then cc instanceof CallContextSomeCall
2810-
else cc instanceof CallContextAny
2811-
) and
2811+
sourceCallCtx(cc) and
28122812
sc instanceof SummaryCtxNone and
28132813
ap = TAccessPathNil(node.getDataFlowType())
28142814
or
@@ -3214,11 +3214,7 @@ module Impl<FullStateConfigSig Config> {
32143214

32153215
override predicate isSource() {
32163216
sourceNode(node, state) and
3217-
(
3218-
if hasSourceCallCtx()
3219-
then cc instanceof CallContextSomeCall
3220-
else cc instanceof CallContextAny
3221-
) and
3217+
sourceCallCtx(cc) and
32223218
sc instanceof SummaryCtxNone and
32233219
ap = TAccessPathNil(node.getDataFlowType())
32243220
}

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ module Impl<FullStateConfigSig Config> {
418418
)
419419
}
420420

421+
private predicate sourceCallCtx(CallContext cc) {
422+
if hasSourceCallCtx() then cc instanceof CallContextSomeCall else cc instanceof CallContextAny
423+
}
424+
421425
private predicate hasSinkCallCtx() {
422426
exists(FlowFeature feature | feature = Config::getAFeature() |
423427
feature instanceof FeatureHasSinkCallContext or
@@ -2804,11 +2808,7 @@ module Impl<FullStateConfigSig Config> {
28042808
// A PathNode is introduced by a source ...
28052809
Stage5::revFlow(node, state) and
28062810
sourceNode(node, state) and
2807-
(
2808-
if hasSourceCallCtx()
2809-
then cc instanceof CallContextSomeCall
2810-
else cc instanceof CallContextAny
2811-
) and
2811+
sourceCallCtx(cc) and
28122812
sc instanceof SummaryCtxNone and
28132813
ap = TAccessPathNil(node.getDataFlowType())
28142814
or
@@ -3214,11 +3214,7 @@ module Impl<FullStateConfigSig Config> {
32143214

32153215
override predicate isSource() {
32163216
sourceNode(node, state) and
3217-
(
3218-
if hasSourceCallCtx()
3219-
then cc instanceof CallContextSomeCall
3220-
else cc instanceof CallContextAny
3221-
) and
3217+
sourceCallCtx(cc) and
32223218
sc instanceof SummaryCtxNone and
32233219
ap = TAccessPathNil(node.getDataFlowType())
32243220
}

go/ql/lib/semmle/go/dataflow/internal/DataFlowImpl.qll

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ module Impl<FullStateConfigSig Config> {
418418
)
419419
}
420420

421+
private predicate sourceCallCtx(CallContext cc) {
422+
if hasSourceCallCtx() then cc instanceof CallContextSomeCall else cc instanceof CallContextAny
423+
}
424+
421425
private predicate hasSinkCallCtx() {
422426
exists(FlowFeature feature | feature = Config::getAFeature() |
423427
feature instanceof FeatureHasSinkCallContext or
@@ -2804,11 +2808,7 @@ module Impl<FullStateConfigSig Config> {
28042808
// A PathNode is introduced by a source ...
28052809
Stage5::revFlow(node, state) and
28062810
sourceNode(node, state) and
2807-
(
2808-
if hasSourceCallCtx()
2809-
then cc instanceof CallContextSomeCall
2810-
else cc instanceof CallContextAny
2811-
) and
2811+
sourceCallCtx(cc) and
28122812
sc instanceof SummaryCtxNone and
28132813
ap = TAccessPathNil(node.getDataFlowType())
28142814
or
@@ -3214,11 +3214,7 @@ module Impl<FullStateConfigSig Config> {
32143214

32153215
override predicate isSource() {
32163216
sourceNode(node, state) and
3217-
(
3218-
if hasSourceCallCtx()
3219-
then cc instanceof CallContextSomeCall
3220-
else cc instanceof CallContextAny
3221-
) and
3217+
sourceCallCtx(cc) and
32223218
sc instanceof SummaryCtxNone and
32233219
ap = TAccessPathNil(node.getDataFlowType())
32243220
}

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ module Impl<FullStateConfigSig Config> {
418418
)
419419
}
420420

421+
private predicate sourceCallCtx(CallContext cc) {
422+
if hasSourceCallCtx() then cc instanceof CallContextSomeCall else cc instanceof CallContextAny
423+
}
424+
421425
private predicate hasSinkCallCtx() {
422426
exists(FlowFeature feature | feature = Config::getAFeature() |
423427
feature instanceof FeatureHasSinkCallContext or
@@ -2804,11 +2808,7 @@ module Impl<FullStateConfigSig Config> {
28042808
// A PathNode is introduced by a source ...
28052809
Stage5::revFlow(node, state) and
28062810
sourceNode(node, state) and
2807-
(
2808-
if hasSourceCallCtx()
2809-
then cc instanceof CallContextSomeCall
2810-
else cc instanceof CallContextAny
2811-
) and
2811+
sourceCallCtx(cc) and
28122812
sc instanceof SummaryCtxNone and
28132813
ap = TAccessPathNil(node.getDataFlowType())
28142814
or
@@ -3214,11 +3214,7 @@ module Impl<FullStateConfigSig Config> {
32143214

32153215
override predicate isSource() {
32163216
sourceNode(node, state) and
3217-
(
3218-
if hasSourceCallCtx()
3219-
then cc instanceof CallContextSomeCall
3220-
else cc instanceof CallContextAny
3221-
) and
3217+
sourceCallCtx(cc) and
32223218
sc instanceof SummaryCtxNone and
32233219
ap = TAccessPathNil(node.getDataFlowType())
32243220
}

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl.qll

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ module Impl<FullStateConfigSig Config> {
418418
)
419419
}
420420

421+
private predicate sourceCallCtx(CallContext cc) {
422+
if hasSourceCallCtx() then cc instanceof CallContextSomeCall else cc instanceof CallContextAny
423+
}
424+
421425
private predicate hasSinkCallCtx() {
422426
exists(FlowFeature feature | feature = Config::getAFeature() |
423427
feature instanceof FeatureHasSinkCallContext or
@@ -2804,11 +2808,7 @@ module Impl<FullStateConfigSig Config> {
28042808
// A PathNode is introduced by a source ...
28052809
Stage5::revFlow(node, state) and
28062810
sourceNode(node, state) and
2807-
(
2808-
if hasSourceCallCtx()
2809-
then cc instanceof CallContextSomeCall
2810-
else cc instanceof CallContextAny
2811-
) and
2811+
sourceCallCtx(cc) and
28122812
sc instanceof SummaryCtxNone and
28132813
ap = TAccessPathNil(node.getDataFlowType())
28142814
or
@@ -3214,11 +3214,7 @@ module Impl<FullStateConfigSig Config> {
32143214

32153215
override predicate isSource() {
32163216
sourceNode(node, state) and
3217-
(
3218-
if hasSourceCallCtx()
3219-
then cc instanceof CallContextSomeCall
3220-
else cc instanceof CallContextAny
3221-
) and
3217+
sourceCallCtx(cc) and
32223218
sc instanceof SummaryCtxNone and
32233219
ap = TAccessPathNil(node.getDataFlowType())
32243220
}

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImpl.qll

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ module Impl<FullStateConfigSig Config> {
418418
)
419419
}
420420

421+
private predicate sourceCallCtx(CallContext cc) {
422+
if hasSourceCallCtx() then cc instanceof CallContextSomeCall else cc instanceof CallContextAny
423+
}
424+
421425
private predicate hasSinkCallCtx() {
422426
exists(FlowFeature feature | feature = Config::getAFeature() |
423427
feature instanceof FeatureHasSinkCallContext or
@@ -2804,11 +2808,7 @@ module Impl<FullStateConfigSig Config> {
28042808
// A PathNode is introduced by a source ...
28052809
Stage5::revFlow(node, state) and
28062810
sourceNode(node, state) and
2807-
(
2808-
if hasSourceCallCtx()
2809-
then cc instanceof CallContextSomeCall
2810-
else cc instanceof CallContextAny
2811-
) and
2811+
sourceCallCtx(cc) and
28122812
sc instanceof SummaryCtxNone and
28132813
ap = TAccessPathNil(node.getDataFlowType())
28142814
or
@@ -3214,11 +3214,7 @@ module Impl<FullStateConfigSig Config> {
32143214

32153215
override predicate isSource() {
32163216
sourceNode(node, state) and
3217-
(
3218-
if hasSourceCallCtx()
3219-
then cc instanceof CallContextSomeCall
3220-
else cc instanceof CallContextAny
3221-
) and
3217+
sourceCallCtx(cc) and
32223218
sc instanceof SummaryCtxNone and
32233219
ap = TAccessPathNil(node.getDataFlowType())
32243220
}

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImpl.qll

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ module Impl<FullStateConfigSig Config> {
418418
)
419419
}
420420

421+
private predicate sourceCallCtx(CallContext cc) {
422+
if hasSourceCallCtx() then cc instanceof CallContextSomeCall else cc instanceof CallContextAny
423+
}
424+
421425
private predicate hasSinkCallCtx() {
422426
exists(FlowFeature feature | feature = Config::getAFeature() |
423427
feature instanceof FeatureHasSinkCallContext or
@@ -2804,11 +2808,7 @@ module Impl<FullStateConfigSig Config> {
28042808
// A PathNode is introduced by a source ...
28052809
Stage5::revFlow(node, state) and
28062810
sourceNode(node, state) and
2807-
(
2808-
if hasSourceCallCtx()
2809-
then cc instanceof CallContextSomeCall
2810-
else cc instanceof CallContextAny
2811-
) and
2811+
sourceCallCtx(cc) and
28122812
sc instanceof SummaryCtxNone and
28132813
ap = TAccessPathNil(node.getDataFlowType())
28142814
or
@@ -3214,11 +3214,7 @@ module Impl<FullStateConfigSig Config> {
32143214

32153215
override predicate isSource() {
32163216
sourceNode(node, state) and
3217-
(
3218-
if hasSourceCallCtx()
3219-
then cc instanceof CallContextSomeCall
3220-
else cc instanceof CallContextAny
3221-
) and
3217+
sourceCallCtx(cc) and
32223218
sc instanceof SummaryCtxNone and
32233219
ap = TAccessPathNil(node.getDataFlowType())
32243220
}

0 commit comments

Comments
 (0)