Skip to content

Commit 2aaf88b

Browse files
Copilotowen-mc
andauthored
Add GotoStmt, Parameter, Throw, Assignment and PatternMatchExpr to Go Ast module for updated shared CFG AstSig
Agent-Logs-Url: https://github.com/github/codeql/sessions/005953d9-1d54-4071-8cd2-5a7d26f65f61 Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
1 parent 3487858 commit 2aaf88b

2 files changed

Lines changed: 488 additions & 35 deletions

File tree

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

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module;
99

1010
private import codeql.controlflow.ControlFlowGraph as CfgLib
1111
private import codeql.controlflow.SuccessorType
12+
private import codeql.util.Void
1213

1314
/** Contains the shared CFG library instantiation for Go. */
1415
module GoCfg {
@@ -72,6 +73,14 @@ module GoCfg {
7273

7374
AstNode callableGetBody(Callable c) { result = c }
7475

76+
class Parameter extends AstNode {
77+
Parameter() { none() }
78+
79+
Expr getDefaultValue() { none() }
80+
}
81+
82+
Parameter callableGetParameter(Callable c, int index) { none() }
83+
7584
Callable getEnclosingCallable(AstNode node) {
7685
result = node and node instanceof Callable
7786
or
@@ -152,12 +161,14 @@ module GoCfg {
152161

153162
class ContinueStmt = Go::ContinueStmt;
154163

164+
class GotoStmt = Go::GotoStmt;
165+
155166
class ReturnStmt extends Go::ReturnStmt {
156167
override Expr getExpr() { result = Go::ReturnStmt.super.getExpr() }
157168
}
158169

159-
class ThrowStmt extends Stmt {
160-
ThrowStmt() { none() }
170+
class Throw extends AstNode {
171+
Throw() { none() }
161172

162173
Expr getExpr() { none() }
163174
}
@@ -241,12 +252,46 @@ module GoCfg {
241252

242253
boolean getValue() { result = val }
243254
}
255+
256+
class Assignment extends BinaryExpr {
257+
Assignment() { none() }
258+
}
259+
260+
class AssignExpr extends Assignment {
261+
AssignExpr() { none() }
262+
}
263+
264+
class CompoundAssignment extends Assignment {
265+
CompoundAssignment() { none() }
266+
}
267+
268+
class AssignLogicalAndExpr extends CompoundAssignment {
269+
AssignLogicalAndExpr() { none() }
270+
}
271+
272+
class AssignLogicalOrExpr extends CompoundAssignment {
273+
AssignLogicalOrExpr() { none() }
274+
}
275+
276+
class AssignNullCoalescingExpr extends CompoundAssignment {
277+
AssignNullCoalescingExpr() { none() }
278+
}
279+
280+
class PatternMatchExpr extends Expr {
281+
PatternMatchExpr() { none() }
282+
283+
Expr getExpr() { none() }
284+
285+
AstNode getPattern() { none() }
286+
}
244287
}
245288

246289
/** The Input module implementing InputSig1 and InputSig2 for Go. */
247290
private module Input implements Cfg0::InputSig1, Cfg1::InputSig2 {
248291
predicate cfgCachedStageRef() { CfgCachedStage::ref() }
249292

293+
class CallableContext = Void;
294+
250295
private newtype TLabel =
251296
TGoLabel(string l) { exists(Go::LabeledStmt ls | l = ls.getLabel()) } or
252297
TFallthrough()

0 commit comments

Comments
 (0)