@@ -268,7 +268,7 @@ class NSRegularExpressionRegexAdditionalFlowStep extends RegexAdditionalFlowStep
268268/**
269269 * An additional flow step for `NSString.CompareOptions`.
270270 */
271- class NSStringRegexAdditionalFlowStep extends RegexAdditionalFlowStep {
271+ private class NSStringRegexAdditionalFlowStep extends RegexAdditionalFlowStep {
272272 override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) { none ( ) }
273273
274274 override predicate setsParseMode ( DataFlow:: Node node , RegexParseMode mode , boolean isSet ) {
@@ -302,6 +302,20 @@ class NSStringRegexAdditionalFlowStep extends RegexAdditionalFlowStep {
302302class RegexEval extends CallExpr instanceof PotentialRegexEval {
303303 RegexEval ( ) { this .( PotentialRegexEval ) .doesEvaluate ( ) }
304304
305+ /**
306+ * Gets the input to this call that is the regular expression being evaluated.
307+ * This may be a regular expression object or a string literal.
308+ *
309+ * Consider using `getARegex()` instead (which tracks the regular expression
310+ * input back to its source).
311+ */
312+ Expr getRegexInput ( ) { result = this .( PotentialRegexEval ) .getRegexInput ( ) .asExpr ( ) }
313+
314+ /**
315+ * Gets the input to this call that is the string the regular expression is evaluated on.
316+ */
317+ Expr getStringInput ( ) { result = this .( PotentialRegexEval ) .getStringInput ( ) .asExpr ( ) }
318+
305319 /**
306320 * Gets a regular expression value that is evaluated here (if any can be identified).
307321 */
@@ -357,11 +371,11 @@ abstract class PotentialRegexEval extends CallExpr {
357371 DataFlow:: Node getAnOptionsInput ( ) { none ( ) }
358372
359373 /**
360- * Holds if this is an actual regular expression evalaution . If this does not
361- * hold, the potential regular expression evaluation should be discarded .
374+ * Holds if this instance actually evaluated a regular expression. If this
375+ * does not hold, a `RegexEval` is not created for this `PotentialRegexEval` .
362376 *
363377 * This mechanism exists so that we have something to track flow of options
364- * into to (for example an `NSString.CompareOptions.regularExpression` option)
378+ * into (for example an `NSString.CompareOptions.regularExpression` option)
365379 * before deciding whether a regular expression is actually evaluated.
366380 */
367381 predicate doesEvaluate ( ) { any ( ) }
@@ -428,12 +442,12 @@ private class AlwaysRegexEval extends PotentialRegexEval {
428442 * A call to a function that sometimes evaluates a regular expression, if
429443 * `NSString.CompareOptions.regularExpression` is set as an `options` argument.
430444 */
431- private class NSStringCompareOptionsMaybeRegexEval extends PotentialRegexEval {
445+ private class NSStringCompareOptionsPotentialRegexEval extends PotentialRegexEval {
432446 DataFlow:: Node regexInput ;
433447 DataFlow:: Node stringInput ;
434448 DataFlow:: Node optionsInput ;
435449
436- NSStringCompareOptionsMaybeRegexEval ( ) {
450+ NSStringCompareOptionsPotentialRegexEval ( ) {
437451 (
438452 this .getStaticTarget ( )
439453 .( Method )
0 commit comments