Merge pull request #22365 from owen-mc/go/shared-guards · github/codeql@887fc4b · GitHub
Skip to content

Commit 887fc4b

Browse files
authored
Merge pull request #22365 from owen-mc/go/shared-guards
Go: Use shared guards library
2 parents ef6059a + 0edfdb1 commit 887fc4b

32 files changed

Lines changed: 1874 additions & 301 deletions

File tree

Lines changed: 4 additions & 0 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* The Go language library now instantiates the shared library `semmle.go.controlflow.Guards`, including the `Guard` and `GuardValue` classes and the `guardEnsures`, `guardEnsuresEq`, `guardEnsuresNeq`, and `guardEnsuresLeq` predicates.

‎go/ql/lib/semmle/go/Expr.qll‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ overlay[local]
55
module;
66

77
import go
8+
private import semmle.go.controlflow.ControlFlowGraphImpl
89

910
/**
1011
* An expression.
@@ -17,6 +18,12 @@ import go
1718
* ```
1819
*/
1920
class Expr extends @expr, ExprParent {
21+
/** Gets the control-flow node associated with this expression. */
22+
CfgImpl::Cfg::ControlFlowNode getControlFlowNode() { result.injects(this) }
23+
24+
/** Gets the basic block containing this expression. */
25+
CfgImpl::Cfg::BasicBlock getBasicBlock() { result = this.getControlFlowNode().getBasicBlock() }
26+
2027
/**
2128
* Gets the kind of this expression, which is an integer value representing the expression's
2229
* node type.

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

Lines changed: 42 additions & 14 deletions

0 commit comments

Comments
 (0)