Skip to content

Commit e5b13d9

Browse files
committed
cache hasLocationInfo and Node::toString in the dataflow stage
1 parent 0edae89 commit e5b13d9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

javascript/ql/src/semmle/javascript/dataflow/DataFlow.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ module DataFlow {
149149
* For more information, see
150150
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
151151
*/
152+
cached
152153
predicate hasLocationInfo(
153154
string filepath, int startline, int startcolumn, int endline, int endcolumn
154155
) {
@@ -171,6 +172,7 @@ module DataFlow {
171172
int getEndColumn() { hasLocationInfo(_, _, _, _, result) }
172173

173174
/** Gets a textual representation of this element. */
175+
cached
174176
string toString() { none() }
175177

176178
/**
@@ -294,12 +296,13 @@ module DataFlow {
294296
override predicate hasLocationInfo(
295297
string filepath, int startline, int startcolumn, int endline, int endcolumn
296298
) {
299+
Stages::DataFlowStage::ref() and
297300
astNode.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
298301
}
299302

300303
override File getFile() { result = astNode.getFile() }
301304

302-
override string toString() { result = astNode.toString() }
305+
override string toString() { Stages::DataFlowStage::ref() and result = astNode.toString() }
303306
}
304307

305308
/**

javascript/ql/src/semmle/javascript/internal/CachedStages.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ module Stages {
126126
exists(any(Expr e).getExceptionTarget())
127127
or
128128
exists(DataFlow::ssaDefinitionNode(_))
129+
or
130+
any(DataFlow::Node node).hasLocationInfo(_, _, _, _, _)
131+
or
132+
exists(any(DataFlow::Node node).toString())
129133
}
130134
}
131135

0 commit comments

Comments
 (0)