Skip to content

Commit 653d122

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

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -1014,19 +1014,19 @@ 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)
1017+
(
1018+
model = getSourceModel(node)
10191019
or
1020-
not knownSourceModel(n, _) and model = ""
1020+
not exists(getSourceModel(node)) and model = ""
10211021
)
10221022
}
10231023

10241024
private predicate sinkModel(NodeEx node, string model) {
10251025
sinkNode(node, _) and
1026-
exists(Node n | n = node.asNodeOrImplicitRead() |
1027-
knownSinkModel(n, model)
1026+
(
1027+
model = getSinkModel(node)
10281028
or
1029-
not knownSinkModel(n, _) and model = ""
1029+
not exists(getSinkModel(node)) and model = ""
10301030
)
10311031
}
10321032

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

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

1066+
cached
1067+
string getSourceModel(NodeEx node) { knownSourceModel(node.asNode(), result) }
1068+
1069+
cached
1070+
string getSinkModel(NodeEx node) { knownSinkModel(node.asNodeOrImplicitRead(), result) }
1071+
10661072
cached
10671073
predicate parameterNode(Node p, DataFlowCallable c, ParameterPosition pos) {
10681074
isParameterNode(p, c, pos)

0 commit comments

Comments
 (0)