Skip to content

Commit 4c8089b

Browse files
committed
JS: Moving 'cache' annotations outside the parameterised module
1 parent c23e501 commit 4c8089b

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,6 @@ module API {
812812
predicate inScope(DataFlow::Node node);
813813
}
814814

815-
cached
816815
private module Stage<StageInputSig S> {
817816
/**
818817
* Holds if `rhs` is the right-hand side of a definition of a node that should have an
@@ -1004,7 +1003,6 @@ module API {
10041003
/**
10051004
* Holds if `rhs` is the right-hand side of a definition of node `nd`.
10061005
*/
1007-
cached
10081006
predicate rhs(TApiNode nd, DataFlow::Node rhs) {
10091007
(S::inScope(rhs) or S::isAdditionalDefRoot(nd)) and
10101008
exists(string m | nd = MkModuleExport(m) | exports(m, rhs))
@@ -1252,7 +1250,6 @@ module API {
12521250
/**
12531251
* Holds if `ref` is a use of node `nd`.
12541252
*/
1255-
cached
12561253
predicate use(TApiNode nd, DataFlow::Node ref) {
12571254
(S::inScope(ref) or S::isAdditionalUseRoot(nd)) and
12581255
(
@@ -1374,7 +1371,6 @@ module API {
13741371
/**
13751372
* Gets a node that is inter-procedurally reachable from `nd`, which is a use of some node.
13761373
*/
1377-
cached
13781374
DataFlow::SourceNode trackUseNode(DataFlow::SourceNode nd) {
13791375
result = trackUseNode(nd, false, 0, "")
13801376
}
@@ -1425,7 +1421,6 @@ module API {
14251421
/**
14261422
* Gets a node that inter-procedurally flows into `nd`, which is a definition of some node.
14271423
*/
1428-
cached
14291424
DataFlow::SourceNode trackDefNode(DataFlow::Node nd) {
14301425
result = trackDefNode(nd, DataFlow::TypeBackTracker::end())
14311426
}
@@ -1448,7 +1443,6 @@ module API {
14481443
/**
14491444
* Holds if there is an edge from `pred` to `succ` in the API graph that is labeled with `lbl`.
14501445
*/
1451-
cached
14521446
predicate edge(TApiNode pred, Label::ApiLabel lbl, TApiNode succ) {
14531447
Stages::ApiStage::ref() and
14541448
exists(string m |
@@ -1514,7 +1508,6 @@ module API {
15141508
* Gets a call to a promisified function represented by `callee` where
15151509
* `bound` arguments have been bound.
15161510
*/
1517-
cached
15181511
DataFlow::InvokeNode getAPromisifiedInvocation(TApiNode callee, int bound, TApiNode succ) {
15191512
exists(DataFlow::SourceNode src |
15201513
use(callee, src) and
@@ -1535,7 +1528,36 @@ module API {
15351528
predicate inScope(DataFlow::Node node) { any() }
15361529
}
15371530

1538-
import Stage<Stage1Input>
1531+
private module Stage1 = Stage<Stage1Input>;
1532+
1533+
cached
1534+
private module Cached {
1535+
cached
1536+
predicate rhs(TApiNode nd, DataFlow::Node rhs) { Stage1::rhs(nd, rhs) }
1537+
1538+
cached
1539+
predicate use(TApiNode nd, DataFlow::Node ref) { Stage1::use(nd, ref) }
1540+
1541+
cached
1542+
DataFlow::SourceNode trackUseNode(DataFlow::SourceNode nd) {
1543+
result = Stage1::trackUseNode(nd)
1544+
}
1545+
1546+
cached
1547+
DataFlow::SourceNode trackDefNode(DataFlow::Node nd) { result = Stage1::trackDefNode(nd) }
1548+
1549+
cached
1550+
predicate edge(TApiNode pred, Label::ApiLabel lbl, TApiNode succ) {
1551+
Stage1::edge(pred, lbl, succ)
1552+
}
1553+
1554+
cached
1555+
DataFlow::InvokeNode getAPromisifiedInvocation(TApiNode callee, int bound, TApiNode succ) {
1556+
result = Stage1::getAPromisifiedInvocation(callee, bound, succ)
1557+
}
1558+
}
1559+
1560+
import Cached
15391561

15401562
/**
15411563
* Holds if there is an edge from `pred` to `succ` in the API graph.

0 commit comments

Comments
 (0)