Skip to content

Commit cc2a531

Browse files
committed
JS: Cache PropRef.getBase
1 parent e13a9c9 commit cc2a531

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ module DataFlow {
492492
* Gets the data flow node corresponding to the base object
493493
* whose property is read from or written to.
494494
*/
495+
cached
495496
abstract Node getBase();
496497

497498
/**
@@ -595,7 +596,10 @@ module DataFlow {
595596

596597
PropLValueAsPropWrite() { astNode instanceof LValue }
597598

598-
override Node getBase() { result = valueNode(astNode.getBase()) }
599+
override Node getBase() {
600+
result = valueNode(astNode.getBase()) and
601+
Stages::DataFlowStage::ref()
602+
}
599603

600604
override Expr getPropertyNameExpr() { result = astNode.getPropertyNameExpr() }
601605

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ module Stages {
133133
exists(any(DataFlow::Node node).toString())
134134
or
135135
exists(any(AccessPath a).getAnInstanceIn(_))
136+
or
137+
exists(any(DataFlow::PropRef ref).getBase())
136138
}
137139
}
138140

0 commit comments

Comments
 (0)