Skip to content

Commit

Permalink
Shared: Define getNode inside cached module
Browse files Browse the repository at this point in the history
  • Loading branch information
paldepind committed Jan 22, 2025
1 parent 9a4bf75 commit e5f419c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions shared/controlflow/codeql/controlflow/BasicBlock.qll
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module Make<LocationSig Location, InputSig<Location> Input> {
BasicBlock getAPredecessor(SuccessorType t) { result.getASuccessor(t) = this }

/** Gets the control flow node at a specific (zero-indexed) position in this basic block. */
Node getNode(int pos) { bbIndex(this.getFirstNode(), result, pos) }
Node getNode(int pos) { result = getNode(this, pos) }

/** Gets a control flow node in this basic block. */
Node getANode() { result = this.getNode(_) }
Expand Down Expand Up @@ -308,10 +308,12 @@ module Make<LocationSig Location, InputSig<Location> Input> {
* Holds if `bbStart` is the first node in a basic block and `cfn` is the
* `i`th node in the same basic block.
*/
cached
predicate bbIndex(Node bbStart, Node cfn, int i) =
private predicate bbIndex(Node bbStart, Node cfn, int i) =
shortestDistances(startsBB/1, intraBBSucc/2)(bbStart, cfn, i)

cached
Node getNode(BasicBlock bb, int pos) { bbIndex(bb.getFirstNode(), result, pos) }

/**
* Holds if the first node of basic block `succ` is a control flow
* successor of the last node of basic block `pred`.
Expand Down

0 comments on commit e5f419c

Please sign in to comment.