mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
C++: Use the word "rank" to denote a rank
Previously, the word "position" was used ambiguously in this library.
This commit is contained in:
@@ -57,7 +57,7 @@ class SubBasicBlock extends ControlFlowNodeBase {
|
|||||||
* predecessors.
|
* predecessors.
|
||||||
*/
|
*/
|
||||||
predicate firstInBB() {
|
predicate firstInBB() {
|
||||||
exists(BasicBlock bb | this.getPosInBasicBlock(bb) = 0)
|
exists(BasicBlock bb | this.getRankInBasicBlock(bb) = 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,19 +66,18 @@ class SubBasicBlock extends ControlFlowNodeBase {
|
|||||||
*/
|
*/
|
||||||
predicate lastInBB() {
|
predicate lastInBB() {
|
||||||
exists(BasicBlock bb |
|
exists(BasicBlock bb |
|
||||||
this.getPosInBasicBlock(bb) = countSubBasicBlocksInBasicBlock(bb) - 1
|
this.getRankInBasicBlock(bb) = countSubBasicBlocksInBasicBlock(bb)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the position of this `SubBasicBlock` in its containing basic block
|
* Gets the rank of this `SubBasicBlock` among the other `SubBasicBlock`s in
|
||||||
* `bb`, where `bb` is equal to `getBasicBlock()`.
|
* its containing basic block `bb`, where `bb` is equal to `getBasicBlock()`.
|
||||||
*/
|
*/
|
||||||
int getPosInBasicBlock(BasicBlock bb) {
|
int getRankInBasicBlock(BasicBlock bb) {
|
||||||
exists(int thisIndexInBB, int rnk |
|
exists(int thisIndexInBB |
|
||||||
thisIndexInBB = this.getIndexInBasicBlock(bb) and
|
thisIndexInBB = this.getIndexInBasicBlock(bb) and
|
||||||
thisIndexInBB = rank[rnk](int i | i = any(SubBasicBlock n).getIndexInBasicBlock(bb)) and
|
thisIndexInBB = rank[result](int i | i = any(SubBasicBlock n).getIndexInBasicBlock(bb))
|
||||||
result = rnk - 1
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +92,7 @@ class SubBasicBlock extends ControlFlowNodeBase {
|
|||||||
result = this.getBasicBlock().getASuccessor()
|
result = this.getBasicBlock().getASuccessor()
|
||||||
or
|
or
|
||||||
exists(BasicBlock bb |
|
exists(BasicBlock bb |
|
||||||
result.getPosInBasicBlock(bb) = this.getPosInBasicBlock(bb) + 1
|
result.getRankInBasicBlock(bb) = this.getRankInBasicBlock(bb) + 1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +167,9 @@ class SubBasicBlock extends ControlFlowNodeBase {
|
|||||||
)
|
)
|
||||||
or
|
or
|
||||||
exists(SubBasicBlock succ, int succPos, int thisRank, int succRank |
|
exists(SubBasicBlock succ, int succPos, int thisRank, int succRank |
|
||||||
thisRank = this.getPosInBasicBlock(bb) and
|
thisRank = this.getRankInBasicBlock(bb) and
|
||||||
succRank = thisRank + 1 and
|
succRank = thisRank + 1 and
|
||||||
succRank = succ.getPosInBasicBlock(bb) and
|
succRank = succ.getRankInBasicBlock(bb) and
|
||||||
bb.getNode(succPos) = succ and
|
bb.getNode(succPos) = succ and
|
||||||
result = succPos - thisPos
|
result = succPos - thisPos
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class SubBasicBlock extends ControlFlowNodeBase {
|
|||||||
* predecessors.
|
* predecessors.
|
||||||
*/
|
*/
|
||||||
predicate firstInBB() {
|
predicate firstInBB() {
|
||||||
exists(BasicBlock bb | this.getPosInBasicBlock(bb) = 0)
|
exists(BasicBlock bb | this.getRankInBasicBlock(bb) = 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,19 +66,18 @@ class SubBasicBlock extends ControlFlowNodeBase {
|
|||||||
*/
|
*/
|
||||||
predicate lastInBB() {
|
predicate lastInBB() {
|
||||||
exists(BasicBlock bb |
|
exists(BasicBlock bb |
|
||||||
this.getPosInBasicBlock(bb) = countSubBasicBlocksInBasicBlock(bb) - 1
|
this.getRankInBasicBlock(bb) = countSubBasicBlocksInBasicBlock(bb)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the position of this `SubBasicBlock` in its containing basic block
|
* Gets the rank of this `SubBasicBlock` among the other `SubBasicBlock`s in
|
||||||
* `bb`, where `bb` is equal to `getBasicBlock()`.
|
* its containing basic block `bb`, where `bb` is equal to `getBasicBlock()`.
|
||||||
*/
|
*/
|
||||||
int getPosInBasicBlock(BasicBlock bb) {
|
int getRankInBasicBlock(BasicBlock bb) {
|
||||||
exists(int thisIndexInBB, int rnk |
|
exists(int thisIndexInBB |
|
||||||
thisIndexInBB = this.getIndexInBasicBlock(bb) and
|
thisIndexInBB = this.getIndexInBasicBlock(bb) and
|
||||||
thisIndexInBB = rank[rnk](int i | i = any(SubBasicBlock n).getIndexInBasicBlock(bb)) and
|
thisIndexInBB = rank[result](int i | i = any(SubBasicBlock n).getIndexInBasicBlock(bb))
|
||||||
result = rnk - 1
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +92,7 @@ class SubBasicBlock extends ControlFlowNodeBase {
|
|||||||
result = this.getBasicBlock().getASuccessor()
|
result = this.getBasicBlock().getASuccessor()
|
||||||
or
|
or
|
||||||
exists(BasicBlock bb |
|
exists(BasicBlock bb |
|
||||||
result.getPosInBasicBlock(bb) = this.getPosInBasicBlock(bb) + 1
|
result.getRankInBasicBlock(bb) = this.getRankInBasicBlock(bb) + 1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +167,9 @@ class SubBasicBlock extends ControlFlowNodeBase {
|
|||||||
)
|
)
|
||||||
or
|
or
|
||||||
exists(SubBasicBlock succ, int succPos, int thisRank, int succRank |
|
exists(SubBasicBlock succ, int succPos, int thisRank, int succRank |
|
||||||
thisRank = this.getPosInBasicBlock(bb) and
|
thisRank = this.getRankInBasicBlock(bb) and
|
||||||
succRank = thisRank + 1 and
|
succRank = thisRank + 1 and
|
||||||
succRank = succ.getPosInBasicBlock(bb) and
|
succRank = succ.getRankInBasicBlock(bb) and
|
||||||
bb.getNode(succPos) = succ and
|
bb.getNode(succPos) = succ and
|
||||||
result = succPos - thisPos
|
result = succPos - thisPos
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user