Skip to content

Commit 2332dad

Browse files
committed
C++: s/pos/index/ in SubBasicBlocks
1 parent 92c354e commit 2332dad

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

cpp/ql/src/semmle/code/cpp/controlflow/SubBasicBlocks.qll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,27 @@ class SubBasicBlock extends ControlFlowNodeBase {
9797
}
9898

9999
/**
100-
* Gets the `pos`th control-flow node in this `SubBasicBlock`. Positions
101-
* start from 0, and the node at position 0 always exists and compares equal
100+
* Gets the `index`th control-flow node in this `SubBasicBlock`. Indexes
101+
* start from 0, and the node at index 0 always exists and compares equal
102102
* to `this`.
103103
*/
104104
pragma[nomagic]
105-
ControlFlowNode getNode(int pos) {
105+
ControlFlowNode getNode(int index) {
106106
exists(BasicBlock bb |
107-
exists(int outerPos |
108-
result = bb.getNode(outerPos) and
109-
pos = outerPosToInnerPos(bb, outerPos)
107+
exists(int outerIndex |
108+
result = bb.getNode(outerIndex) and
109+
index = outerToInnerIndex(bb, outerIndex)
110110
)
111111
)
112112
}
113113

114+
/**
115+
* Gets the index of the node in this `SubBasicBlock` that has `indexInBB` in
116+
* `bb`, where `bb` is equal to `getBasicBlock()`.
117+
*/
114118
pragma[nomagic]
115-
private int outerPosToInnerPos(BasicBlock bb, int posInBB) {
116-
posInBB = result + this.getIndexInBasicBlock(bb) and
119+
private int outerToInnerIndex(BasicBlock bb, int indexInBB) {
120+
indexInBB = result + this.getIndexInBasicBlock(bb) and
117121
result = [ 0 .. this.getNumberOfNodes() - 1 ]
118122
}
119123

cpp/ql/src/semmle/code/cpp/dataflow/internal/SubBasicBlocks.qll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,27 @@ class SubBasicBlock extends ControlFlowNodeBase {
9797
}
9898

9999
/**
100-
* Gets the `pos`th control-flow node in this `SubBasicBlock`. Positions
101-
* start from 0, and the node at position 0 always exists and compares equal
100+
* Gets the `index`th control-flow node in this `SubBasicBlock`. Indexes
101+
* start from 0, and the node at index 0 always exists and compares equal
102102
* to `this`.
103103
*/
104104
pragma[nomagic]
105-
ControlFlowNode getNode(int pos) {
105+
ControlFlowNode getNode(int index) {
106106
exists(BasicBlock bb |
107-
exists(int outerPos |
108-
result = bb.getNode(outerPos) and
109-
pos = outerPosToInnerPos(bb, outerPos)
107+
exists(int outerIndex |
108+
result = bb.getNode(outerIndex) and
109+
index = outerToInnerIndex(bb, outerIndex)
110110
)
111111
)
112112
}
113113

114+
/**
115+
* Gets the index of the node in this `SubBasicBlock` that has `indexInBB` in
116+
* `bb`, where `bb` is equal to `getBasicBlock()`.
117+
*/
114118
pragma[nomagic]
115-
private int outerPosToInnerPos(BasicBlock bb, int posInBB) {
116-
posInBB = result + this.getIndexInBasicBlock(bb) and
119+
private int outerToInnerIndex(BasicBlock bb, int indexInBB) {
120+
indexInBB = result + this.getIndexInBasicBlock(bb) and
117121
result = [ 0 .. this.getNumberOfNodes() - 1 ]
118122
}
119123

0 commit comments

Comments
 (0)