Skip to content

Commit b2f8782

Browse files
committed
Use shared getASuccessor and getAPredecessor
1 parent 3dd6b3f commit b2f8782

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

go/ql/lib/semmle/go/controlflow/BasicBlocks.qll

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ private module Input implements BB::InputSig<Location> {
4343
private module BbImpl = BB::Make<Location, Input>;
4444

4545
class BasicBlock extends BbImpl::BasicBlock {
46-
/** Gets a basic block succeeding this one. */
47-
BasicBlock getASuccessor() { result = this.getASuccessor(_) }
48-
49-
/** Gets a basic block preceding this one. */
50-
BasicBlock getAPredecessor() { result.getASuccessor() = this }
51-
5246
/** Gets the innermost function or file to which this basic block belongs. */
5347
ControlFlow::Root getRoot() { result = this.getScope() }
5448
}
@@ -59,7 +53,7 @@ cached
5953
private predicate reachableBB(BasicBlock bb) {
6054
bb instanceof EntryBasicBlock
6155
or
62-
exists(BasicBlock predBB | predBB.getASuccessor() = bb | reachableBB(predBB))
56+
exists(BasicBlock predBB | predBB.getASuccessor(_) = bb | reachableBB(predBB))
6357
}
6458

6559
/**

go/ql/lib/semmle/go/dataflow/SSA.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ abstract class SsaPseudoDefinition extends SsaImplicitDefinition {
285285
*/
286286
class SsaPhiNode extends SsaPseudoDefinition, TPhi {
287287
override SsaVariable getAnInput() {
288-
result = getDefReachingEndOf(this.getBasicBlock().getAPredecessor(), this.getSourceVariable())
288+
result = getDefReachingEndOf(this.getBasicBlock().getAPredecessor(_), this.getSourceVariable())
289289
}
290290

291291
override predicate definesAt(ReachableBasicBlock bb, int i, SsaSourceVariable v) {

go/ql/lib/semmle/go/dataflow/SsaImpl.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private module Internal {
186186
* Holds if `v` is live at the beginning of any successor of basic block `bb`.
187187
*/
188188
private predicate liveAtSuccEntry(ReachableBasicBlock bb, SsaSourceVariable v) {
189-
liveAtEntry(bb.getASuccessor(), v)
189+
liveAtEntry(bb.getASuccessor(_), v)
190190
}
191191

192192
/**
@@ -317,7 +317,7 @@ private module Internal {
317317
SsaSourceVariable v, ReachableBasicBlock b1, ReachableBasicBlock b2
318318
) {
319319
varOccursInBlock(v, b1) and
320-
b2 = b1.getASuccessor()
320+
b2 = b1.getASuccessor(_)
321321
}
322322

323323
/**
@@ -335,7 +335,7 @@ private module Internal {
335335
) {
336336
varBlockReaches(v, b1, mid) and
337337
not varOccursInBlock(v, mid) and
338-
b2 = mid.getASuccessor()
338+
b2 = mid.getASuccessor(_)
339339
}
340340

341341
/**

go/ql/src/Security/CWE-020/IncompleteHostnameRegexp.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ predicate writesHttpError(ReachableBasicBlock b) {
4545
predicate onlyErrors(BasicBlock block) {
4646
writesHttpError(block)
4747
or
48-
forex(ReachableBasicBlock pred | pred = block.getAPredecessor() | onlyErrors(pred))
48+
forex(ReachableBasicBlock pred | pred = block.getAPredecessor(_) | onlyErrors(pred))
4949
}
5050

5151
/** Gets a node that refers to a handler that is considered to return an HTTP error. */

0 commit comments

Comments
 (0)