Skip to content

Commit e20c57a

Browse files
owen-mcCopilot
andcommitted
Guards: remove boolean outcome block hook
Keep support for compound guards represented by CFG after-value nodes out of the Go shared-guards migration. This behavior can be reconsidered as part of a broader Guards/CFG integration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6aedc51 commit e20c57a

3 files changed

Lines changed: 0 additions & 29 deletions

File tree

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ private module GuardsInput implements
2626

2727
class Expr = G::Expr;
2828

29-
predicate booleanOutcomeBlock(Expr guard, CfgImpl::Cfg::BasicBlock outcomeBlock, boolean branch) {
30-
exists(CfgImpl::Cfg::ControlFlowNode outcomeNode |
31-
branch = true and outcomeNode.isAfterTrue(guard)
32-
or
33-
branch = false and outcomeNode.isAfterFalse(guard)
34-
|
35-
outcomeBlock = outcomeNode.getBasicBlock()
36-
)
37-
}
38-
3929
private newtype TConstantValue = TStringValue(string s) { s = any(G::Expr e).getStringValue() }
4030

4131
class ConstantValue extends TConstantValue {

‎go/ql/test/library-tests/semmle/go/controlflow/Guards/Guards.expected‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ controlsResult
1515
| guards.go:42:2:43:33 | case clause | tagged false comparison | true |
1616
| guards.go:42:7:42:17 | ...<... | tagged false comparison | false |
1717
| guards.go:48:5:48:5 | a | compound true | true |
18-
| guards.go:48:5:48:17 | ...&&... | compound false | false |
19-
| guards.go:48:5:48:17 | ...&&... | compound true | true |
20-
| guards.go:48:11:48:16 | ...\|\|... | compound true | true |
2118
| guards.go:56:5:56:20 | ...==... | upcast | true |
2219
| guards.go:59:5:59:19 | ...==... | downcast | true |
2320
| guards.go:62:5:62:22 | ...==... | upcast narrow | true |
@@ -86,9 +83,6 @@ valueControlsResult
8683
| guards.go:42:7:42:12 | number | tagged false comparison | Lower bound 10 |
8784
| guards.go:42:7:42:17 | ...<... | tagged false comparison | false |
8885
| guards.go:48:5:48:5 | a | compound true | true |
89-
| guards.go:48:5:48:17 | ...&&... | compound false | false |
90-
| guards.go:48:5:48:17 | ...&&... | compound true | true |
91-
| guards.go:48:11:48:16 | ...\|\|... | compound true | true |
9286
| guards.go:56:5:56:15 | type conversion | upcast | 0 |
9387
| guards.go:56:5:56:20 | ...==... | upcast | true |
9488
| guards.go:56:11:56:14 | wide | upcast | 0 |

‎shared/controlflow/codeql/controlflow/Guards.qll‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ signature module InputSig<LocationSig Location, TypSig ControlFlowNode, TypSig B
7878
BasicBlock getBasicBlock();
7979
}
8080

81-
/**
82-
* Holds if `outcomeBlock` contains a control flow node indicating that
83-
* `guard` evaluated to `branch`.
84-
*/
85-
default predicate booleanOutcomeBlock(Expr guard, BasicBlock outcomeBlock, boolean branch) {
86-
none()
87-
}
88-
8981
class ConstantValue {
9082
/** Gets a textual representation of this constant value. */
9183
string toString();
@@ -1540,11 +1532,6 @@ module Make<
15401532
dominatingEdge(guard, succ) and
15411533
succ.dominates(bb)
15421534
)
1543-
or
1544-
exists(BasicBlock outcomeBlock |
1545-
booleanOutcomeBlock(this, outcomeBlock, v.asBooleanValue()) and
1546-
outcomeBlock.dominates(bb)
1547-
)
15481535
}
15491536

15501537
/**

0 commit comments

Comments
 (0)