@@ -268,7 +268,7 @@ class NSRegularExpressionRegexAdditionalFlowStep extends RegexAdditionalFlowStep
268
268
/**
269
269
* An additional flow step for `NSString.CompareOptions`.
270
270
*/
271
- class NSStringRegexAdditionalFlowStep extends RegexAdditionalFlowStep {
271
+ private class NSStringRegexAdditionalFlowStep extends RegexAdditionalFlowStep {
272
272
override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) { none ( ) }
273
273
274
274
override predicate setsParseMode ( DataFlow:: Node node , RegexParseMode mode , boolean isSet ) {
@@ -302,6 +302,20 @@ class NSStringRegexAdditionalFlowStep extends RegexAdditionalFlowStep {
302
302
class RegexEval extends CallExpr instanceof PotentialRegexEval {
303
303
RegexEval ( ) { this .( PotentialRegexEval ) .doesEvaluate ( ) }
304
304
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
+
305
319
/**
306
320
* Gets a regular expression value that is evaluated here (if any can be identified).
307
321
*/
@@ -357,11 +371,11 @@ abstract class PotentialRegexEval extends CallExpr {
357
371
DataFlow:: Node getAnOptionsInput ( ) { none ( ) }
358
372
359
373
/**
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` .
362
376
*
363
377
* 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)
365
379
* before deciding whether a regular expression is actually evaluated.
366
380
*/
367
381
predicate doesEvaluate ( ) { any ( ) }
@@ -428,12 +442,12 @@ private class AlwaysRegexEval extends PotentialRegexEval {
428
442
* A call to a function that sometimes evaluates a regular expression, if
429
443
* `NSString.CompareOptions.regularExpression` is set as an `options` argument.
430
444
*/
431
- private class NSStringCompareOptionsMaybeRegexEval extends PotentialRegexEval {
445
+ private class NSStringCompareOptionsPotentialRegexEval extends PotentialRegexEval {
432
446
DataFlow:: Node regexInput ;
433
447
DataFlow:: Node stringInput ;
434
448
DataFlow:: Node optionsInput ;
435
449
436
- NSStringCompareOptionsMaybeRegexEval ( ) {
450
+ NSStringCompareOptionsPotentialRegexEval ( ) {
437
451
(
438
452
this .getStaticTarget ( )
439
453
.( Method )
0 commit comments