Skip to content

Commit a258489

Browse files
committed
JS: Refactor some internal methods to make them easier to alias
We need these to return the dominator instead of declaring it in the parameter list, so that we can use it directly to fulfill part of the signature for the SSA library. We can't rewrite it with an inline predicate since the SSA module calls with a transitive closure '*', which does not permit inline predicates.
1 parent 443987b commit a258489

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

javascript/ql/lib/semmle/javascript/BasicBlocks.qll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ private module Internal {
102102

103103
private import Internal
104104

105-
/** Holds if `dom` is an immediate dominator of `bb`. */
105+
/** Gets the immediate dominator of `bb`. */
106106
cached
107-
private predicate bbIDominates(BasicBlock dom, BasicBlock bb) =
108-
idominance(entryBB/1, succBB/2)(_, dom, bb)
107+
private BasicBlock immediateDominator(BasicBlock bb) =
108+
idominance(entryBB/1, succBB/2)(_, result, bb)
109109

110-
/** Holds if `dom` is an immediate post-dominator of `bb`. */
110+
/** Gets the immediate post-dominator of `bb`. */
111111
cached
112-
private predicate bbIPostDominates(BasicBlock dom, BasicBlock bb) =
113-
idominance(exitBB/1, predBB/2)(_, dom, bb)
112+
private BasicBlock immediatePostDominator(BasicBlock bb) =
113+
idominance(exitBB/1, predBB/2)(_, result, bb)
114114

115115
/**
116116
* A basic block, that is, a maximal straight-line sequence of control flow nodes
@@ -279,7 +279,7 @@ class BasicBlock extends @cfg_node, NodeInStmtContainer {
279279
/**
280280
* Gets the basic block that immediately dominates this basic block.
281281
*/
282-
ReachableBasicBlock getImmediateDominator() { bbIDominates(result, this) }
282+
ReachableBasicBlock getImmediateDominator() { result = immediateDominator(this) }
283283
}
284284

285285
/**
@@ -308,29 +308,29 @@ class ReachableBasicBlock extends BasicBlock {
308308
* Holds if this basic block strictly dominates `bb`.
309309
*/
310310
pragma[inline]
311-
predicate strictlyDominates(ReachableBasicBlock bb) { bbIDominates+(this, bb) }
311+
predicate strictlyDominates(ReachableBasicBlock bb) { this = immediateDominator+(bb) }
312312

313313
/**
314314
* Holds if this basic block dominates `bb`.
315315
*
316316
* This predicate is reflexive: each reachable basic block dominates itself.
317317
*/
318318
pragma[inline]
319-
predicate dominates(ReachableBasicBlock bb) { bbIDominates*(this, bb) }
319+
predicate dominates(ReachableBasicBlock bb) { this = immediateDominator*(bb) }
320320

321321
/**
322322
* Holds if this basic block strictly post-dominates `bb`.
323323
*/
324324
pragma[inline]
325-
predicate strictlyPostDominates(ReachableBasicBlock bb) { bbIPostDominates+(this, bb) }
325+
predicate strictlyPostDominates(ReachableBasicBlock bb) { this = immediatePostDominator+(bb) }
326326

327327
/**
328328
* Holds if this basic block post-dominates `bb`.
329329
*
330330
* This predicate is reflexive: each reachable basic block post-dominates itself.
331331
*/
332332
pragma[inline]
333-
predicate postDominates(ReachableBasicBlock bb) { bbIPostDominates*(this, bb) }
333+
predicate postDominates(ReachableBasicBlock bb) { this = immediatePostDominator*(bb) }
334334
}
335335

336336
/**

0 commit comments

Comments
 (0)