Skip to content

Commit 02100b8

Browse files
committed
Address review comments
1 parent 77ddd48 commit 02100b8

2 files changed

Lines changed: 8 additions & 26 deletions

File tree

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ module ControlFlow {
5050
predicate isJoin() { strictcount(this.getAPredecessor()) > 1 }
5151

5252
/** Holds if this is the first control-flow node in `subtree`. */
53-
predicate isFirstNodeOf(AstNode subtree) {
54-
this.isBefore(subtree)
55-
or
56-
this.injects(subtree)
57-
}
53+
predicate isFirstNodeOf(AstNode subtree) { this.isBefore(subtree) }
5854

5955
/** Holds if this node is the unique entry node of a file or function. */
6056
predicate isEntryNode() { this instanceof CfgImpl::ControlFlow::EntryNode }

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

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ module CfgImpl {
164164
not this = any(Go::SelectStmt sel).getBody()
165165
}
166166

167-
override Stmt getStmt(int n) { result = Go::BlockStmt.super.getStmt(n) }
168-
169167
Stmt getLastStmt() {
170168
exists(int last | result = this.getStmt(last) and not exists(this.getStmt(last + 1)))
171169
}
@@ -183,10 +181,8 @@ module CfgImpl {
183181
Expr getExpr() { result = Go::ExprStmt.super.getExpr() }
184182
}
185183

186-
class IfStmt extends Stmt {
187-
IfStmt() { this instanceof Go::IfStmt }
188-
189-
Expr getCondition() { result = this.(Go::IfStmt).getCond() }
184+
class IfStmt extends Stmt instanceof Go::IfStmt {
185+
Expr getCondition() { result = this.(Go::IfStmt).getCondition() }
190186

191187
Stmt getThen() { result = this.(Go::IfStmt).getThen() }
192188

@@ -195,9 +191,7 @@ module CfgImpl {
195191

196192
AstNode getIfInit(IfStmt ifstmt) { result = ifstmt.(Go::IfStmt).getInit() }
197193

198-
class LoopStmt extends Stmt {
199-
LoopStmt() { this instanceof Go::LoopStmt }
200-
194+
class LoopStmt extends Stmt instanceof Go::LoopStmt {
201195
Stmt getBody() { result = this.(Go::LoopStmt).getBody() }
202196
}
203197

@@ -219,19 +213,15 @@ module CfgImpl {
219213
Expr getCondition() { none() }
220214
}
221215

222-
class ForStmt extends LoopStmt {
223-
ForStmt() { this instanceof Go::ForStmt }
224-
216+
class ForStmt extends LoopStmt instanceof Go::ForStmt {
225217
AstNode getInit(int index) { index = 0 and result = this.(Go::ForStmt).getInit() }
226218

227219
Expr getCondition() { result = this.(Go::ForStmt).getCond() }
228220

229221
AstNode getUpdate(int index) { index = 0 and result = this.(Go::ForStmt).getPost() }
230222
}
231223

232-
class ForeachStmt extends LoopStmt {
233-
ForeachStmt() { this instanceof Go::RangeStmt }
234-
224+
class ForeachStmt extends LoopStmt instanceof Go::RangeStmt {
235225
// Go's `range` statement binds its key and value by destructuring the
236226
// current element. The extractor synthesizes a single "range element"
237227
// node grouping the key and value (see `Go::RangeElementExpr`), which we
@@ -249,9 +239,7 @@ module CfgImpl {
249239

250240
class GotoStmt = Go::GotoStmt;
251241

252-
class ReturnStmt extends Go::ReturnStmt {
253-
override Expr getExpr() { result = Go::ReturnStmt.super.getExpr() }
254-
}
242+
class ReturnStmt = Go::ReturnStmt;
255243

256244
class Throw extends AstNode {
257245
Throw() { none() }
@@ -281,9 +269,7 @@ module CfgImpl {
281269
Stmt getBody() { none() }
282270
}
283271

284-
class Switch extends AstNode {
285-
Switch() { this instanceof Go::SwitchStmt }
286-
272+
class Switch extends AstNode instanceof Go::SwitchStmt {
287273
Expr getExpr() {
288274
result = this.(Go::ExpressionSwitchStmt).getExpr()
289275
or

0 commit comments

Comments
 (0)