Skip to content

Commit 8b257aa

Browse files
committed
Data flow: Cache known{Source,Sink}Model
1 parent a7bb952 commit 8b257aa

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll

+2-10
Original file line numberDiff line numberDiff line change
@@ -1014,20 +1014,12 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
10141014

10151015
private predicate sourceModel(NodeEx node, string model) {
10161016
sourceNode(node, _) and
1017-
exists(Node n | n = node.asNode() |
1018-
knownSourceModel(n, model)
1019-
or
1020-
not knownSourceModel(n, _) and model = ""
1021-
)
1017+
model = getSourceModel(node)
10221018
}
10231019

10241020
private predicate sinkModel(NodeEx node, string model) {
10251021
sinkNode(node, _) and
1026-
exists(Node n | n = node.asNodeOrImplicitRead() |
1027-
knownSinkModel(n, model)
1028-
or
1029-
not knownSinkModel(n, _) and model = ""
1030-
)
1022+
model = getSinkModel(node)
10311023
}
10321024

10331025
bindingset[label1, label2]

shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll

+18
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,24 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
10631063
exists(n.asParamReturnNode())
10641064
}
10651065

1066+
cached
1067+
string getSourceModel(NodeEx node) {
1068+
exists(Node n | n = node.asNode() |
1069+
knownSourceModel(n, result)
1070+
or
1071+
not knownSourceModel(n, _) and result = ""
1072+
)
1073+
}
1074+
1075+
cached
1076+
string getSinkModel(NodeEx node) {
1077+
exists(Node n | n = node.asNode() |
1078+
knownSinkModel(n, result)
1079+
or
1080+
not knownSinkModel(n, _) and result = ""
1081+
)
1082+
}
1083+
10661084
cached
10671085
predicate parameterNode(Node p, DataFlowCallable c, ParameterPosition pos) {
10681086
isParameterNode(p, c, pos)

0 commit comments

Comments
 (0)