1
1
private import rust
2
2
private import codeql.util.Boolean
3
+ private import Completion
3
4
4
5
newtype TLoopJumpType =
5
6
TContinueJump ( ) or
@@ -14,45 +15,43 @@ newtype TSuccessorType =
14
15
TSuccessorSuccessor ( ) or
15
16
TBooleanSuccessor ( Boolean b ) or
16
17
TMatchSuccessor ( Boolean b ) or
17
- TLoopSuccessor ( TLoopJumpType kind , TLabelType label ) or
18
+ TLoopSuccessor ( TLoopJumpType kind , TLabelType label ) { exists ( TLoopCompletion ( kind , label ) ) } or
18
19
TReturnSuccessor ( )
19
20
20
21
/** The type of a control flow successor. */
21
- abstract private class SuccessorTypeImpl extends TSuccessorType {
22
+ abstract class SuccessorTypeImpl extends TSuccessorType {
22
23
/** Gets a textual representation of successor type. */
23
24
abstract string toString ( ) ;
24
25
}
25
26
26
- final class SuccessorType = SuccessorTypeImpl ;
27
-
28
27
/** A normal control flow successor. */
29
- final class NormalSuccessor extends SuccessorTypeImpl , TSuccessorSuccessor {
30
- final override string toString ( ) { result = "successor" }
28
+ class NormalSuccessorImpl extends SuccessorTypeImpl , TSuccessorSuccessor {
29
+ override string toString ( ) { result = "successor" }
31
30
}
32
31
33
32
/** A conditional control flow successor. */
34
- abstract private class ConditionalSuccessor extends SuccessorTypeImpl {
33
+ abstract class ConditionalSuccessorImpl extends SuccessorTypeImpl {
35
34
boolean value ;
36
35
37
36
bindingset [ value]
38
- ConditionalSuccessor ( ) { any ( ) }
37
+ ConditionalSuccessorImpl ( ) { any ( ) }
39
38
40
39
/** Gets the Boolean value of this successor. */
41
- final boolean getValue ( ) { result = value }
40
+ boolean getValue ( ) { result = value }
42
41
}
43
42
44
43
/** A Boolean control flow successor for a boolean conditon. */
45
- final class BooleanSuccessor extends ConditionalSuccessor , TBooleanSuccessor {
46
- BooleanSuccessor ( ) { this = TBooleanSuccessor ( value ) }
44
+ class BooleanSuccessorImpl extends ConditionalSuccessorImpl , TBooleanSuccessor {
45
+ BooleanSuccessorImpl ( ) { this = TBooleanSuccessor ( value ) }
47
46
48
47
override string toString ( ) { result = this .getValue ( ) .toString ( ) }
49
48
}
50
49
51
50
/**
52
51
* A control flow successor of a pattern match.
53
52
*/
54
- final class MatchSuccessor extends ConditionalSuccessor , TMatchSuccessor {
55
- MatchSuccessor ( ) { this = TMatchSuccessor ( value ) }
53
+ class MatchSuccessorImpl extends ConditionalSuccessorImpl , TMatchSuccessor {
54
+ MatchSuccessorImpl ( ) { this = TMatchSuccessor ( value ) }
56
55
57
56
override string toString ( ) {
58
57
if this .getValue ( ) = true then result = "match" else result = "no-match"
@@ -62,20 +61,20 @@ final class MatchSuccessor extends ConditionalSuccessor, TMatchSuccessor {
62
61
/**
63
62
* A control flow successor of a loop control flow expression, `continue` or `break`.
64
63
*/
65
- final class LoopJumpSuccessor extends SuccessorTypeImpl , TLoopSuccessor {
66
- final private TLoopJumpType getKind ( ) { this = TLoopSuccessor ( result , _) }
64
+ class LoopJumpSuccessorImpl extends SuccessorTypeImpl , TLoopSuccessor {
65
+ private TLoopJumpType getKind ( ) { this = TLoopSuccessor ( result , _) }
67
66
68
- final private TLabelType getLabelType ( ) { this = TLoopSuccessor ( _, result ) }
67
+ private TLabelType getLabelType ( ) { this = TLoopSuccessor ( _, result ) }
69
68
70
- final predicate hasLabel ( ) { this .getLabelType ( ) = TLabel ( _) }
69
+ predicate hasLabel ( ) { this .getLabelType ( ) = TLabel ( _) }
71
70
72
- final string getLabelName ( ) { this = TLoopSuccessor ( _, TLabel ( result ) ) }
71
+ string getLabelName ( ) { this = TLoopSuccessor ( _, TLabel ( result ) ) }
73
72
74
- final predicate isContinue ( ) { this .getKind ( ) = TContinueJump ( ) }
73
+ predicate isContinue ( ) { this .getKind ( ) = TContinueJump ( ) }
75
74
76
- final predicate isBreak ( ) { this .getKind ( ) = TBreakJump ( ) }
75
+ predicate isBreak ( ) { this .getKind ( ) = TBreakJump ( ) }
77
76
78
- final override string toString ( ) {
77
+ override string toString ( ) {
79
78
exists ( string kind , string label |
80
79
( if this .isContinue ( ) then kind = "continue" else kind = "break" ) and
81
80
( if this .hasLabel ( ) then label = "(" + this .getLabelName ( ) + ")" else label = "" ) and
@@ -87,6 +86,6 @@ final class LoopJumpSuccessor extends SuccessorTypeImpl, TLoopSuccessor {
87
86
/**
88
87
* A `return` control flow successor.
89
88
*/
90
- final class ReturnSuccessor extends SuccessorTypeImpl , TReturnSuccessor {
91
- final override string toString ( ) { result = "return" }
89
+ class ReturnSuccessorImpl extends SuccessorTypeImpl , TReturnSuccessor {
90
+ override string toString ( ) { result = "return" }
92
91
}
0 commit comments