Skip to content

Commit ee84832

Browse files
authored
Merge pull request github#3442 from erik-krogh/SmallPerfs
Approved by esbena
2 parents 451ae7b + bd768cb commit ee84832

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

javascript/ql/src/semmle/javascript/CFG.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,9 @@ class GuardControlFlowNode extends SyntheticControlFlowNode, @guard_node {
379379
* is known to hold at `bb`.
380380
*/
381381
predicate dominates(ReachableBasicBlock bb) {
382-
this = bb.getANode() or
383-
dominates(bb.getImmediateDominator())
382+
this = bb.getANode()
383+
or
384+
exists(ReachableBasicBlock prev | prev.strictlyDominates(bb) | this = prev.getANode())
384385
}
385386
}
386387

javascript/ql/src/semmle/javascript/InclusionTests.qll

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,22 @@ module InclusionTest {
7171
count(this.getACallee()) = 1 and
7272
count(callee.getAReturnedExpr()) = 1 and
7373
not this.isImprecise() and
74-
inner.getContainerNode().getALocalSource().getEnclosingExpr() = callee.getAParameter() and
75-
inner.getContainedNode().getALocalSource().getEnclosingExpr() = callee.getAParameter()
74+
inner.getContainedNode().getALocalSource() = DataFlow::parameterNode(callee.getAParameter()) and
75+
inner.getContainerNode().getALocalSource() = DataFlow::parameterNode(callee.getAParameter())
7676
}
7777

7878
override DataFlow::Node getContainerNode() {
7979
exists(int arg |
80-
inner.getContainerNode().getALocalSource().getEnclosingExpr() = callee.getParameter(arg) and
80+
inner.getContainerNode().getALocalSource() =
81+
DataFlow::parameterNode(callee.getParameter(arg)) and
8182
result = this.getArgument(arg)
8283
)
8384
}
8485

8586
override DataFlow::Node getContainedNode() {
8687
exists(int arg |
87-
inner.getContainedNode().getALocalSource().getEnclosingExpr() = callee.getParameter(arg) and
88+
inner.getContainedNode().getALocalSource() =
89+
DataFlow::parameterNode(callee.getParameter(arg)) and
8890
result = this.getArgument(arg)
8991
)
9092
}

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -726,21 +726,6 @@ private predicate basicFlowStepNoBarrier(
726726
summary = PathSummary::return()
727727
}
728728

729-
/**
730-
* Holds if there is a flow step from `pred` to `succ` described by `summary`
731-
* under configuration `cfg`.
732-
*
733-
* Summary steps through function calls are not taken into account.
734-
*/
735-
private predicate basicFlowStep(
736-
DataFlow::Node pred, DataFlow::Node succ, PathSummary summary, DataFlow::Configuration cfg
737-
) {
738-
basicFlowStepNoBarrier(pred, succ, summary, cfg) and
739-
isRelevant(pred, cfg) and
740-
not isLabeledBarrierEdge(cfg, pred, succ, summary.getStartLabel()) and
741-
not isBarrierEdge(cfg, pred, succ)
742-
}
743-
744729
/**
745730
* Holds if there is a flow step from `pred` to `succ` under configuration `cfg`,
746731
* including both basic flow steps and steps into/out of properties.
@@ -1339,7 +1324,8 @@ private predicate flowStep(
13391324
DataFlow::Node pred, DataFlow::Configuration cfg, DataFlow::Node succ, PathSummary summary
13401325
) {
13411326
(
1342-
basicFlowStep(pred, succ, summary, cfg)
1327+
basicFlowStepNoBarrier(pred, succ, summary, cfg) and
1328+
isRelevant(pred, cfg)
13431329
or
13441330
// Flow through a function that returns a value that depends on one of its arguments
13451331
// or a captured variable

0 commit comments

Comments
 (0)