Skip to content

Commit 5cffa59

Browse files
committed
Swift: Make the RegexEval interface cleaner.
1 parent 987ca61 commit 5cffa59

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

swift/ql/lib/codeql/swift/regex/Regex.qll

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,15 @@ private class ParsedStringRegex extends RegExp, StringLiteralExpr {
6060
* ```
6161
*/
6262
abstract class RegexEval extends CallExpr {
63-
Expr regexInput;
64-
Expr stringInput;
65-
6663
/**
6764
* Gets the input to this call that is the regular expression being evaluated.
6865
*/
69-
Expr getRegexInput() { result = regexInput }
66+
abstract Expr getRegexInput();
7067

7168
/**
7269
* Gets the input to this call that is the string the regular expression is evaluated on.
7370
*/
74-
Expr getStringInput() { result = stringInput }
71+
abstract Expr getStringInput();
7572

7673
/**
7774
* Gets a regular expression value that is evaluated here (if any can be identified).
@@ -83,6 +80,9 @@ abstract class RegexEval extends CallExpr {
8380
* A call to a function that always evaluates a regular expression.
8481
*/
8582
private class AlwaysRegexEval extends RegexEval {
83+
Expr regexInput;
84+
Expr stringInput;
85+
8686
AlwaysRegexEval() {
8787
this.getStaticTarget()
8888
.(Method)
@@ -127,4 +127,8 @@ private class AlwaysRegexEval extends RegexEval {
127127
regexInput = this.getArgument(0).getExpr() and
128128
stringInput = this.getQualifier()
129129
}
130+
131+
override Expr getRegexInput() { result = regexInput }
132+
133+
override Expr getStringInput() { result = stringInput }
130134
}

0 commit comments

Comments
 (0)