Skip to content

Commit cecf92c

Browse files
committed
Use shared getASuccessor and getAPredecessor
1 parent d55c6d2 commit cecf92c

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@ private module BbImpl = BB::Make<Location, Input>;
4646

4747
// import BbImpl
4848
class BasicBlock extends BbImpl::BasicBlock {
49-
/** Gets an immediate successor of this basic block of a given type, if any. */
50-
BasicBlock getASuccessor(SuccessorType t) { result = super.getASuccessor(t) }
51-
52-
/** Gets a basic block succeeding this one. */
53-
BasicBlock getASuccessor() { result = this.getASuccessor(_) }
54-
55-
/** Gets a basic block preceding this one. */
56-
BasicBlock getAPredecessor() { result.getASuccessor() = this }
57-
5849
/** Gets the basic block that immediately dominates this basic block. */
5950
ReachableBasicBlock getImmediateDominator() { result.immediatelyDominates(this) }
6051

@@ -66,7 +57,7 @@ cached
6657
private predicate reachableBB(BasicBlock bb) {
6758
bb instanceof BbImpl::EntryBasicBlock
6859
or
69-
exists(BasicBlock predBB | predBB.getASuccessor() = bb | reachableBB(predBB))
60+
exists(BasicBlock predBB | predBB.getASuccessor(_) = bb | reachableBB(predBB))
7061
}
7162

7263
/**

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)