Skip to content

Commit 7122d9e

Browse files
committed
Rust: Use shared SuccessorType.
1 parent dd6c628 commit 7122d9e

File tree

5 files changed

+6
-100
lines changed

5 files changed

+6
-100
lines changed
Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
/** Provides classes representing the control flow graph. */
22

33
private import internal.ControlFlowGraphImpl
4-
private import internal.SuccessorType
54
private import internal.Scope as Scope
5+
import codeql.controlflow.SuccessorType
66

77
final class CfgScope = Scope::CfgScope;
88

9-
final class SuccessorType = SuccessorTypeImpl;
10-
11-
final class NormalSuccessor = NormalSuccessorImpl;
12-
13-
final class ConditionalSuccessor = ConditionalSuccessorImpl;
14-
15-
final class BooleanSuccessor = BooleanSuccessorImpl;
16-
17-
final class MatchSuccessor = MatchSuccessorImpl;
18-
19-
final class BreakSuccessor = BreakSuccessorImpl;
20-
21-
final class ContinueSuccessor = ContinueSuccessorImpl;
22-
23-
final class ReturnSuccessor = ReturnSuccessorImpl;
24-
259
final class CfgNode = Node;

rust/ql/lib/codeql/rust/controlflow/internal/Completion.qll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
private import codeql.util.Boolean
22
private import codeql.rust.controlflow.ControlFlowGraph
33
private import rust
4-
private import SuccessorType
54

65
newtype TCompletion =
76
TSimpleCompletion() or
@@ -32,7 +31,7 @@ abstract class NormalCompletion extends Completion { }
3231

3332
/** A simple (normal) completion. */
3433
class SimpleCompletion extends NormalCompletion, TSimpleCompletion {
35-
override NormalSuccessor getAMatchingSuccessorType() { any() }
34+
override DirectSuccessor getAMatchingSuccessorType() { any() }
3635

3736
// `SimpleCompletion` is the "default" completion type, thus it is valid for
3837
// any node where there isn't another more specific completion type.
@@ -184,7 +183,7 @@ class MatchCompletion extends TMatchCompletion, ConditionalCompletion {
184183
e instanceof TryExpr and value = true
185184
}
186185

187-
override MatchSuccessor getAMatchingSuccessorType() { result.getValue() = value }
186+
override MatchingSuccessor getAMatchingSuccessorType() { result.getValue() = value }
188187

189188
/** Gets the dual match completion. */
190189
override MatchCompletion getDual() { result = TMatchCompletion(value.booleanNot()) }
@@ -196,7 +195,7 @@ class MatchCompletion extends TMatchCompletion, ConditionalCompletion {
196195
* A completion that represents a `break`.
197196
*/
198197
class BreakCompletion extends TBreakCompletion, Completion {
199-
override BreakSuccessor getAMatchingSuccessorType() { any() }
198+
override JumpSuccessor getAMatchingSuccessorType() { any() }
200199

201200
override predicate isValidForSpecific(AstNode e) { e instanceof BreakExpr }
202201

@@ -207,7 +206,7 @@ class BreakCompletion extends TBreakCompletion, Completion {
207206
* A completion that represents a `continue`.
208207
*/
209208
class ContinueCompletion extends TContinueCompletion, Completion {
210-
override ContinueSuccessor getAMatchingSuccessorType() { any() }
209+
override JumpSuccessor getAMatchingSuccessorType() { any() }
211210

212211
override predicate isValidForSpecific(AstNode e) { e instanceof ContinueExpr }
213212

rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private module CfgInput implements InputSig<Location> {
3737
/**
3838
* Hold if `c` represents simple (normal) evaluation of a statement or an expression.
3939
*/
40-
predicate successorTypeIsSimple(SuccessorType t) { t instanceof Cfg::NormalSuccessor }
40+
predicate successorTypeIsSimple(SuccessorType t) { t instanceof Cfg::DirectSuccessor }
4141

4242
/** Holds if `t` is an abnormal exit type out of a CFG scope. */
4343
predicate isAbnormalExitType(SuccessorType t) { none() }

rust/ql/lib/codeql/rust/controlflow/internal/SuccessorType.qll

Lines changed: 0 additions & 74 deletions
This file was deleted.

rust/ql/lib/codeql/rust/internal/CachedStages.qll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ module Stages {
6565
cached
6666
module CfgStage {
6767
private import codeql.rust.controlflow.internal.Splitting
68-
private import codeql.rust.controlflow.internal.SuccessorType
6968
private import codeql.rust.controlflow.internal.ControlFlowGraphImpl
7069
private import codeql.rust.controlflow.CfgNodes
7170

@@ -87,8 +86,6 @@ module Stages {
8786
or
8887
exists(TConditionalCompletionSplitKind())
8988
or
90-
exists(TNormalSuccessor())
91-
or
9289
exists(AstCfgNode n)
9390
or
9491
exists(CallExprCfgNode n | exists(n.getFunction()))

0 commit comments

Comments
 (0)