re2/re2/simplify.cc
Go to the documentation of this file.
1 // Copyright 2006 The RE2 Authors. All Rights Reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4 
5 // Rewrite POSIX and other features in re
6 // to use simple extended regular expression features.
7 // Also sort and simplify character classes.
8 
9 #include <string>
10 
11 #include "util/util.h"
12 #include "util/logging.h"
13 #include "util/utf.h"
14 #include "re2/pod_array.h"
15 #include "re2/regexp.h"
16 #include "re2/walker-inl.h"
17 
18 namespace re2 {
19 
20 // Parses the regexp src and then simplifies it and sets *dst to the
21 // string representation of the simplified form. Returns true on success.
22 // Returns false and sets *error (if error != NULL) on error.
23 bool Regexp::SimplifyRegexp(const StringPiece& src, ParseFlags flags,
24  std::string* dst, RegexpStatus* status) {
25  Regexp* re = Parse(src, flags, status);
26  if (re == NULL)
27  return false;
28  Regexp* sre = re->Simplify();
29  re->Decref();
30  if (sre == NULL) {
31  if (status) {
32  status->set_code(kRegexpInternalError);
33  status->set_error_arg(src);
34  }
35  return false;
36  }
37  *dst = sre->ToString();
38  sre->Decref();
39  return true;
40 }
41 
42 // Assuming the simple_ flags on the children are accurate,
43 // is this Regexp* simple?
44 bool Regexp::ComputeSimple() {
45  Regexp** subs;
46  switch (op_) {
47  case kRegexpNoMatch:
48  case kRegexpEmptyMatch:
49  case kRegexpLiteral:
51  case kRegexpBeginLine:
52  case kRegexpEndLine:
53  case kRegexpBeginText:
56  case kRegexpEndText:
57  case kRegexpAnyChar:
58  case kRegexpAnyByte:
59  case kRegexpHaveMatch:
60  return true;
61  case kRegexpConcat:
62  case kRegexpAlternate:
63  // These are simple as long as the subpieces are simple.
64  subs = sub();
65  for (int i = 0; i < nsub_; i++)
66  if (!subs[i]->simple())
67  return false;
68  return true;
69  case kRegexpCharClass:
70  // Simple as long as the char class is not empty, not full.
71  if (ccb_ != NULL)
72  return !ccb_->empty() && !ccb_->full();
73  return !cc_->empty() && !cc_->full();
74  case kRegexpCapture:
75  subs = sub();
76  return subs[0]->simple();
77  case kRegexpStar:
78  case kRegexpPlus:
79  case kRegexpQuest:
80  subs = sub();
81  if (!subs[0]->simple())
82  return false;
83  switch (subs[0]->op_) {
84  case kRegexpStar:
85  case kRegexpPlus:
86  case kRegexpQuest:
87  case kRegexpEmptyMatch:
88  case kRegexpNoMatch:
89  return false;
90  default:
91  break;
92  }
93  return true;
94  case kRegexpRepeat:
95  return false;
96  }
97  LOG(DFATAL) << "Case not handled in ComputeSimple: " << op_;
98  return false;
99 }
100 
101 // Walker subclass used by Simplify.
102 // Coalesces runs of star/plus/quest/repeat of the same literal along with any
103 // occurrences of that literal into repeats of that literal. It also works for
104 // char classes, any char and any byte.
105 // PostVisit creates the coalesced result, which should then be simplified.
106 class CoalesceWalker : public Regexp::Walker<Regexp*> {
107  public:
109  virtual Regexp* PostVisit(Regexp* re, Regexp* parent_arg, Regexp* pre_arg,
110  Regexp** child_args, int nchild_args);
111  virtual Regexp* Copy(Regexp* re);
112  virtual Regexp* ShortVisit(Regexp* re, Regexp* parent_arg);
113 
114  private:
115  // These functions are declared inside CoalesceWalker so that
116  // they can edit the private fields of the Regexps they construct.
117 
118  // Returns true if r1 and r2 can be coalesced. In particular, ensures that
119  // the parse flags are consistent. (They will not be checked again later.)
120  static bool CanCoalesce(Regexp* r1, Regexp* r2);
121 
122  // Coalesces *r1ptr and *r2ptr. In most cases, the array elements afterwards
123  // will be empty match and the coalesced op. In other cases, where part of a
124  // literal string was removed to be coalesced, the array elements afterwards
125  // will be the coalesced op and the remainder of the literal string.
126  static void DoCoalesce(Regexp** r1ptr, Regexp** r2ptr);
127 
128  CoalesceWalker(const CoalesceWalker&) = delete;
129  CoalesceWalker& operator=(const CoalesceWalker&) = delete;
130 };
131 
132 // Walker subclass used by Simplify.
133 // The simplify walk is purely post-recursive: given the simplified children,
134 // PostVisit creates the simplified result.
135 // The child_args are simplified Regexp*s.
136 class SimplifyWalker : public Regexp::Walker<Regexp*> {
137  public:
139  virtual Regexp* PreVisit(Regexp* re, Regexp* parent_arg, bool* stop);
140  virtual Regexp* PostVisit(Regexp* re, Regexp* parent_arg, Regexp* pre_arg,
141  Regexp** child_args, int nchild_args);
142  virtual Regexp* Copy(Regexp* re);
143  virtual Regexp* ShortVisit(Regexp* re, Regexp* parent_arg);
144 
145  private:
146  // These functions are declared inside SimplifyWalker so that
147  // they can edit the private fields of the Regexps they construct.
148 
149  // Creates a concatenation of two Regexp, consuming refs to re1 and re2.
150  // Caller must Decref return value when done with it.
152 
153  // Simplifies the expression re{min,max} in terms of *, +, and ?.
154  // Returns a new regexp. Does not edit re. Does not consume reference to re.
155  // Caller must Decref return value when done with it.
156  static Regexp* SimplifyRepeat(Regexp* re, int min, int max,
157  Regexp::ParseFlags parse_flags);
158 
159  // Simplifies a character class by expanding any named classes
160  // into rune ranges. Does not edit re. Does not consume ref to re.
161  // Caller must Decref return value when done with it.
162  static Regexp* SimplifyCharClass(Regexp* re);
163 
164  SimplifyWalker(const SimplifyWalker&) = delete;
165  SimplifyWalker& operator=(const SimplifyWalker&) = delete;
166 };
167 
168 // Simplifies a regular expression, returning a new regexp.
169 // The new regexp uses traditional Unix egrep features only,
170 // plus the Perl (?:) non-capturing parentheses.
171 // Otherwise, no POSIX or Perl additions. The new regexp
172 // captures exactly the same subexpressions (with the same indices)
173 // as the original.
174 // Does not edit current object.
175 // Caller must Decref() return value when done with it.
176 
177 Regexp* Regexp::Simplify() {
178  CoalesceWalker cw;
179  Regexp* cre = cw.Walk(this, NULL);
180  if (cre == NULL)
181  return NULL;
182  if (cw.stopped_early()) {
183  cre->Decref();
184  return NULL;
185  }
186  SimplifyWalker sw;
187  Regexp* sre = sw.Walk(cre, NULL);
188  cre->Decref();
189  if (sre == NULL)
190  return NULL;
191  if (sw.stopped_early()) {
192  sre->Decref();
193  return NULL;
194  }
195  return sre;
196 }
197 
198 #define Simplify DontCallSimplify // Avoid accidental recursion
199 
200 // Utility function for PostVisit implementations that compares re->sub() with
201 // child_args to determine whether any child_args changed. In the common case,
202 // where nothing changed, calls Decref() for all child_args and returns false,
203 // so PostVisit must return re->Incref(). Otherwise, returns true.
204 static bool ChildArgsChanged(Regexp* re, Regexp** child_args) {
205  for (int i = 0; i < re->nsub(); i++) {
206  Regexp* sub = re->sub()[i];
207  Regexp* newsub = child_args[i];
208  if (newsub != sub)
209  return true;
210  }
211  for (int i = 0; i < re->nsub(); i++) {
212  Regexp* newsub = child_args[i];
213  newsub->Decref();
214  }
215  return false;
216 }
217 
218 Regexp* CoalesceWalker::Copy(Regexp* re) {
219  return re->Incref();
220 }
221 
222 Regexp* CoalesceWalker::ShortVisit(Regexp* re, Regexp* parent_arg) {
223  // Should never be called: we use Walk(), not WalkExponential().
224 #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
225  LOG(DFATAL) << "CoalesceWalker::ShortVisit called";
226 #endif
227  return re->Incref();
228 }
229 
230 Regexp* CoalesceWalker::PostVisit(Regexp* re,
231  Regexp* parent_arg,
232  Regexp* pre_arg,
233  Regexp** child_args,
234  int nchild_args) {
235  if (re->nsub() == 0)
236  return re->Incref();
237 
238  if (re->op() != kRegexpConcat) {
239  if (!ChildArgsChanged(re, child_args))
240  return re->Incref();
241 
242  // Something changed. Build a new op.
243  Regexp* nre = new Regexp(re->op(), re->parse_flags());
244  nre->AllocSub(re->nsub());
245  Regexp** nre_subs = nre->sub();
246  for (int i = 0; i < re->nsub(); i++)
247  nre_subs[i] = child_args[i];
248  // Repeats and Captures have additional data that must be copied.
249  if (re->op() == kRegexpRepeat) {
250  nre->min_ = re->min();
251  nre->max_ = re->max();
252  } else if (re->op() == kRegexpCapture) {
253  nre->cap_ = re->cap();
254  }
255  return nre;
256  }
257 
258  bool can_coalesce = false;
259  for (int i = 0; i < re->nsub(); i++) {
260  if (i+1 < re->nsub() &&
261  CanCoalesce(child_args[i], child_args[i+1])) {
262  can_coalesce = true;
263  break;
264  }
265  }
266  if (!can_coalesce) {
267  if (!ChildArgsChanged(re, child_args))
268  return re->Incref();
269 
270  // Something changed. Build a new op.
271  Regexp* nre = new Regexp(re->op(), re->parse_flags());
272  nre->AllocSub(re->nsub());
273  Regexp** nre_subs = nre->sub();
274  for (int i = 0; i < re->nsub(); i++)
275  nre_subs[i] = child_args[i];
276  return nre;
277  }
278 
279  for (int i = 0; i < re->nsub(); i++) {
280  if (i+1 < re->nsub() &&
281  CanCoalesce(child_args[i], child_args[i+1]))
282  DoCoalesce(&child_args[i], &child_args[i+1]);
283  }
284  // Determine how many empty matches were left by DoCoalesce.
285  int n = 0;
286  for (int i = n; i < re->nsub(); i++) {
287  if (child_args[i]->op() == kRegexpEmptyMatch)
288  n++;
289  }
290  // Build a new op.
291  Regexp* nre = new Regexp(re->op(), re->parse_flags());
292  nre->AllocSub(re->nsub() - n);
293  Regexp** nre_subs = nre->sub();
294  for (int i = 0, j = 0; i < re->nsub(); i++) {
295  if (child_args[i]->op() == kRegexpEmptyMatch) {
296  child_args[i]->Decref();
297  continue;
298  }
299  nre_subs[j] = child_args[i];
300  j++;
301  }
302  return nre;
303 }
304 
305 bool CoalesceWalker::CanCoalesce(Regexp* r1, Regexp* r2) {
306  // r1 must be a star/plus/quest/repeat of a literal, char class, any char or
307  // any byte.
308  if ((r1->op() == kRegexpStar ||
309  r1->op() == kRegexpPlus ||
310  r1->op() == kRegexpQuest ||
311  r1->op() == kRegexpRepeat) &&
312  (r1->sub()[0]->op() == kRegexpLiteral ||
313  r1->sub()[0]->op() == kRegexpCharClass ||
314  r1->sub()[0]->op() == kRegexpAnyChar ||
315  r1->sub()[0]->op() == kRegexpAnyByte)) {
316  // r2 must be a star/plus/quest/repeat of the same literal, char class,
317  // any char or any byte.
318  if ((r2->op() == kRegexpStar ||
319  r2->op() == kRegexpPlus ||
320  r2->op() == kRegexpQuest ||
321  r2->op() == kRegexpRepeat) &&
322  Regexp::Equal(r1->sub()[0], r2->sub()[0]) &&
323  // The parse flags must be consistent.
324  ((r1->parse_flags() & Regexp::NonGreedy) ==
325  (r2->parse_flags() & Regexp::NonGreedy))) {
326  return true;
327  }
328  // ... OR an occurrence of that literal, char class, any char or any byte
329  if (Regexp::Equal(r1->sub()[0], r2)) {
330  return true;
331  }
332  // ... OR a literal string that begins with that literal.
333  if (r1->sub()[0]->op() == kRegexpLiteral &&
334  r2->op() == kRegexpLiteralString &&
335  r2->runes()[0] == r1->sub()[0]->rune() &&
336  // The parse flags must be consistent.
337  ((r1->sub()[0]->parse_flags() & Regexp::FoldCase) ==
338  (r2->parse_flags() & Regexp::FoldCase))) {
339  return true;
340  }
341  }
342  return false;
343 }
344 
345 void CoalesceWalker::DoCoalesce(Regexp** r1ptr, Regexp** r2ptr) {
346  Regexp* r1 = *r1ptr;
347  Regexp* r2 = *r2ptr;
348 
349  Regexp* nre = Regexp::Repeat(
350  r1->sub()[0]->Incref(), r1->parse_flags(), 0, 0);
351 
352  switch (r1->op()) {
353  case kRegexpStar:
354  nre->min_ = 0;
355  nre->max_ = -1;
356  break;
357 
358  case kRegexpPlus:
359  nre->min_ = 1;
360  nre->max_ = -1;
361  break;
362 
363  case kRegexpQuest:
364  nre->min_ = 0;
365  nre->max_ = 1;
366  break;
367 
368  case kRegexpRepeat:
369  nre->min_ = r1->min();
370  nre->max_ = r1->max();
371  break;
372 
373  default:
374  LOG(DFATAL) << "DoCoalesce failed: r1->op() is " << r1->op();
375  nre->Decref();
376  return;
377  }
378 
379  switch (r2->op()) {
380  case kRegexpStar:
381  nre->max_ = -1;
382  goto LeaveEmpty;
383 
384  case kRegexpPlus:
385  nre->min_++;
386  nre->max_ = -1;
387  goto LeaveEmpty;
388 
389  case kRegexpQuest:
390  if (nre->max() != -1)
391  nre->max_++;
392  goto LeaveEmpty;
393 
394  case kRegexpRepeat:
395  nre->min_ += r2->min();
396  if (r2->max() == -1)
397  nre->max_ = -1;
398  else if (nre->max() != -1)
399  nre->max_ += r2->max();
400  goto LeaveEmpty;
401 
402  case kRegexpLiteral:
403  case kRegexpCharClass:
404  case kRegexpAnyChar:
405  case kRegexpAnyByte:
406  nre->min_++;
407  if (nre->max() != -1)
408  nre->max_++;
409  goto LeaveEmpty;
410 
411  LeaveEmpty:
412  *r1ptr = new Regexp(kRegexpEmptyMatch, Regexp::NoParseFlags);
413  *r2ptr = nre;
414  break;
415 
416  case kRegexpLiteralString: {
417  Rune r = r1->sub()[0]->rune();
418  // Determine how much of the literal string is removed.
419  // We know that we have at least one rune. :)
420  int n = 1;
421  while (n < r2->nrunes() && r2->runes()[n] == r)
422  n++;
423  nre->min_ += n;
424  if (nre->max() != -1)
425  nre->max_ += n;
426  if (n == r2->nrunes())
427  goto LeaveEmpty;
428  *r1ptr = nre;
429  *r2ptr = Regexp::LiteralString(
430  &r2->runes()[n], r2->nrunes() - n, r2->parse_flags());
431  break;
432  }
433 
434  default:
435  LOG(DFATAL) << "DoCoalesce failed: r2->op() is " << r2->op();
436  nre->Decref();
437  return;
438  }
439 
440  r1->Decref();
441  r2->Decref();
442 }
443 
444 Regexp* SimplifyWalker::Copy(Regexp* re) {
445  return re->Incref();
446 }
447 
448 Regexp* SimplifyWalker::ShortVisit(Regexp* re, Regexp* parent_arg) {
449  // Should never be called: we use Walk(), not WalkExponential().
450 #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
451  LOG(DFATAL) << "SimplifyWalker::ShortVisit called";
452 #endif
453  return re->Incref();
454 }
455 
456 Regexp* SimplifyWalker::PreVisit(Regexp* re, Regexp* parent_arg, bool* stop) {
457  if (re->simple()) {
458  *stop = true;
459  return re->Incref();
460  }
461  return NULL;
462 }
463 
464 Regexp* SimplifyWalker::PostVisit(Regexp* re,
465  Regexp* parent_arg,
466  Regexp* pre_arg,
467  Regexp** child_args,
468  int nchild_args) {
469  switch (re->op()) {
470  case kRegexpNoMatch:
471  case kRegexpEmptyMatch:
472  case kRegexpLiteral:
474  case kRegexpBeginLine:
475  case kRegexpEndLine:
476  case kRegexpBeginText:
477  case kRegexpWordBoundary:
479  case kRegexpEndText:
480  case kRegexpAnyChar:
481  case kRegexpAnyByte:
482  case kRegexpHaveMatch:
483  // All these are always simple.
484  re->simple_ = true;
485  return re->Incref();
486 
487  case kRegexpConcat:
488  case kRegexpAlternate: {
489  // These are simple as long as the subpieces are simple.
490  if (!ChildArgsChanged(re, child_args)) {
491  re->simple_ = true;
492  return re->Incref();
493  }
494  Regexp* nre = new Regexp(re->op(), re->parse_flags());
495  nre->AllocSub(re->nsub());
496  Regexp** nre_subs = nre->sub();
497  for (int i = 0; i < re->nsub(); i++)
498  nre_subs[i] = child_args[i];
499  nre->simple_ = true;
500  return nre;
501  }
502 
503  case kRegexpCapture: {
504  Regexp* newsub = child_args[0];
505  if (newsub == re->sub()[0]) {
506  newsub->Decref();
507  re->simple_ = true;
508  return re->Incref();
509  }
510  Regexp* nre = new Regexp(kRegexpCapture, re->parse_flags());
511  nre->AllocSub(1);
512  nre->sub()[0] = newsub;
513  nre->cap_ = re->cap();
514  nre->simple_ = true;
515  return nre;
516  }
517 
518  case kRegexpStar:
519  case kRegexpPlus:
520  case kRegexpQuest: {
521  Regexp* newsub = child_args[0];
522  // Special case: repeat the empty string as much as
523  // you want, but it's still the empty string.
524  if (newsub->op() == kRegexpEmptyMatch)
525  return newsub;
526 
527  // These are simple as long as the subpiece is simple.
528  if (newsub == re->sub()[0]) {
529  newsub->Decref();
530  re->simple_ = true;
531  return re->Incref();
532  }
533 
534  // These are also idempotent if flags are constant.
535  if (re->op() == newsub->op() &&
536  re->parse_flags() == newsub->parse_flags())
537  return newsub;
538 
539  Regexp* nre = new Regexp(re->op(), re->parse_flags());
540  nre->AllocSub(1);
541  nre->sub()[0] = newsub;
542  nre->simple_ = true;
543  return nre;
544  }
545 
546  case kRegexpRepeat: {
547  Regexp* newsub = child_args[0];
548  // Special case: repeat the empty string as much as
549  // you want, but it's still the empty string.
550  if (newsub->op() == kRegexpEmptyMatch)
551  return newsub;
552 
553  Regexp* nre = SimplifyRepeat(newsub, re->min_, re->max_,
554  re->parse_flags());
555  newsub->Decref();
556  nre->simple_ = true;
557  return nre;
558  }
559 
560  case kRegexpCharClass: {
561  Regexp* nre = SimplifyCharClass(re);
562  nre->simple_ = true;
563  return nre;
564  }
565  }
566 
567  LOG(ERROR) << "Simplify case not handled: " << re->op();
568  return re->Incref();
569 }
570 
571 // Creates a concatenation of two Regexp, consuming refs to re1 and re2.
572 // Returns a new Regexp, handing the ref to the caller.
573 Regexp* SimplifyWalker::Concat2(Regexp* re1, Regexp* re2,
574  Regexp::ParseFlags parse_flags) {
575  Regexp* re = new Regexp(kRegexpConcat, parse_flags);
576  re->AllocSub(2);
577  Regexp** subs = re->sub();
578  subs[0] = re1;
579  subs[1] = re2;
580  return re;
581 }
582 
583 // Simplifies the expression re{min,max} in terms of *, +, and ?.
584 // Returns a new regexp. Does not edit re. Does not consume reference to re.
585 // Caller must Decref return value when done with it.
586 // The result will *not* necessarily have the right capturing parens
587 // if you call ToString() and re-parse it: (x){2} becomes (x)(x),
588 // but in the Regexp* representation, both (x) are marked as $1.
589 Regexp* SimplifyWalker::SimplifyRepeat(Regexp* re, int min, int max,
590  Regexp::ParseFlags f) {
591  // x{n,} means at least n matches of x.
592  if (max == -1) {
593  // Special case: x{0,} is x*
594  if (min == 0)
595  return Regexp::Star(re->Incref(), f);
596 
597  // Special case: x{1,} is x+
598  if (min == 1)
599  return Regexp::Plus(re->Incref(), f);
600 
601  // General case: x{4,} is xxxx+
602  PODArray<Regexp*> nre_subs(min);
603  for (int i = 0; i < min-1; i++)
604  nre_subs[i] = re->Incref();
605  nre_subs[min-1] = Regexp::Plus(re->Incref(), f);
606  return Regexp::Concat(nre_subs.data(), min, f);
607  }
608 
609  // Special case: (x){0} matches only empty string.
610  if (min == 0 && max == 0)
611  return new Regexp(kRegexpEmptyMatch, f);
612 
613  // Special case: x{1} is just x.
614  if (min == 1 && max == 1)
615  return re->Incref();
616 
617  // General case: x{n,m} means n copies of x and m copies of x?.
618  // The machine will do less work if we nest the final m copies,
619  // so that x{2,5} = xx(x(x(x)?)?)?
620 
621  // Build leading prefix: xx. Capturing only on the last one.
622  Regexp* nre = NULL;
623  if (min > 0) {
624  PODArray<Regexp*> nre_subs(min);
625  for (int i = 0; i < min; i++)
626  nre_subs[i] = re->Incref();
627  nre = Regexp::Concat(nre_subs.data(), min, f);
628  }
629 
630  // Build and attach suffix: (x(x(x)?)?)?
631  if (max > min) {
632  Regexp* suf = Regexp::Quest(re->Incref(), f);
633  for (int i = min+1; i < max; i++)
634  suf = Regexp::Quest(Concat2(re->Incref(), suf, f), f);
635  if (nre == NULL)
636  nre = suf;
637  else
638  nre = Concat2(nre, suf, f);
639  }
640 
641  if (nre == NULL) {
642  // Some degenerate case, like min > max, or min < max < 0.
643  // This shouldn't happen, because the parser rejects such regexps.
644  LOG(DFATAL) << "Malformed repeat " << re->ToString() << " " << min << " " << max;
645  return new Regexp(kRegexpNoMatch, f);
646  }
647 
648  return nre;
649 }
650 
651 // Simplifies a character class.
652 // Caller must Decref return value when done with it.
653 Regexp* SimplifyWalker::SimplifyCharClass(Regexp* re) {
654  CharClass* cc = re->cc();
655 
656  // Special cases
657  if (cc->empty())
658  return new Regexp(kRegexpNoMatch, re->parse_flags());
659  if (cc->full())
660  return new Regexp(kRegexpAnyChar, re->parse_flags());
661 
662  return re->Incref();
663 }
664 
665 } // namespace re2
re2::CharClass::full
bool full()
Definition: bloaty/third_party/re2/re2/regexp.h:252
re2::CharClass::empty
bool empty()
Definition: bloaty/third_party/re2/re2/regexp.h:251
re2::kRegexpEmptyMatch
@ kRegexpEmptyMatch
Definition: bloaty/third_party/re2/re2/regexp.h:107
re2::kRegexpBeginLine
@ kRegexpBeginLine
Definition: bloaty/third_party/re2/re2/regexp.h:142
dst
static const char dst[]
Definition: test-fs-copyfile.c:37
re2::kRegexpNoWordBoundary
@ kRegexpNoWordBoundary
Definition: bloaty/third_party/re2/re2/regexp.h:149
re2::CoalesceWalker::PostVisit
virtual Regexp * PostVisit(Regexp *re, Regexp *parent_arg, Regexp *pre_arg, Regexp **child_args, int nchild_args)
Definition: bloaty/third_party/re2/re2/simplify.cc:221
absl::str_format_internal::LengthMod::j
@ j
re2::CharClassBuilder::empty
bool empty()
Definition: bloaty/third_party/re2/re2/regexp.h:601
re2::Regexp::cc_
CharClass * cc_
Definition: bloaty/third_party/re2/re2/regexp.h:577
re2::Regexp::Decref
void Decref()
Definition: bloaty/third_party/re2/re2/regexp.cc:115
re2::CoalesceWalker::ShortVisit
virtual Regexp * ShortVisit(Regexp *re, Regexp *parent_arg)
Definition: bloaty/third_party/re2/re2/simplify.cc:214
re2::Regexp::Plus
static Regexp * Plus(Regexp *sub, ParseFlags flags)
Definition: bloaty/third_party/re2/re2/regexp.cc:222
re2::Regexp::Star
static Regexp * Star(Regexp *sub, ParseFlags flags)
Definition: bloaty/third_party/re2/re2/regexp.cc:226
re2::Regexp::op_
uint8_t op_
Definition: bloaty/third_party/re2/re2/regexp.h:520
re2::kRegexpLiteralString
@ kRegexpLiteralString
Definition: bloaty/third_party/re2/re2/regexp.h:113
re2::Regexp
Definition: bloaty/third_party/re2/re2/regexp.h:274
re2::SimplifyWalker::Copy
virtual Regexp * Copy(Regexp *re)
Definition: bloaty/third_party/re2/re2/simplify.cc:435
re2::Regexp::nsub
int nsub()
Definition: bloaty/third_party/re2/re2/regexp.h:322
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
re2::ChildArgsChanged
static bool ChildArgsChanged(Regexp *re, Regexp **child_args)
Definition: bloaty/third_party/re2/re2/simplify.cc:196
re2::kRegexpLiteral
@ kRegexpLiteral
Definition: bloaty/third_party/re2/re2/regexp.h:110
pod_array.h
status
absl::Status status
Definition: rls.cc:251
re2
Definition: bloaty/third_party/re2/re2/bitmap256.h:17
re2::Regexp::Concat
static Regexp * Concat(Regexp **subs, int nsubs, ParseFlags flags)
Definition: bloaty/third_party/re2/re2/regexp.cc:286
re2::Regexp::cc
CharClass * cc()
Definition: bloaty/third_party/re2/re2/regexp.h:337
re2::kRegexpHaveMatch
@ kRegexpHaveMatch
Definition: bloaty/third_party/re2/re2/regexp.h:161
re2::kRegexpWordBoundary
@ kRegexpWordBoundary
Definition: bloaty/third_party/re2/re2/regexp.h:147
re2::SimplifyWalker
Definition: bloaty/third_party/re2/re2/simplify.cc:138
re2::Regexp::LiteralString
static Regexp * LiteralString(Rune *runes, int nrunes, ParseFlags flags)
Definition: bloaty/third_party/re2/re2/regexp.cc:321
re2::kRegexpEndText
@ kRegexpEndText
Definition: bloaty/third_party/re2/re2/regexp.h:154
re2::SimplifyWalker::PreVisit
virtual Regexp * PreVisit(Regexp *re, Regexp *parent_arg, bool *stop)
Definition: bloaty/third_party/re2/re2/simplify.cc:446
re2::Regexp::simple
bool simple()
Definition: bloaty/third_party/re2/re2/regexp.h:323
re2::SimplifyWalker::SimplifyWalker
SimplifyWalker()
Definition: re2/re2/simplify.cc:138
re2::Regexp::NoParseFlags
@ NoParseFlags
Definition: bloaty/third_party/re2/re2/regexp.h:279
re2::kRegexpConcat
@ kRegexpConcat
Definition: bloaty/third_party/re2/re2/regexp.h:116
re2::SimplifyWalker::ShortVisit
virtual Regexp * ShortVisit(Regexp *re, Regexp *parent_arg)
Definition: bloaty/third_party/re2/re2/simplify.cc:439
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
LOG
#define LOG(severity)
Definition: bloaty/third_party/re2/util/logging.h:53
re2::kRegexpAnyChar
@ kRegexpAnyChar
Definition: bloaty/third_party/re2/re2/regexp.h:136
re2::Regexp::ComputeSimple
bool ComputeSimple()
Definition: bloaty/third_party/re2/re2/simplify.cc:46
re2::SimplifyWalker::PostVisit
virtual Regexp * PostVisit(Regexp *re, Regexp *parent_arg, Regexp *pre_arg, Regexp **child_args, int nchild_args)
Definition: bloaty/third_party/re2/re2/simplify.cc:454
re2::Regexp::SimplifyRegexp
static bool SimplifyRegexp(const StringPiece &src, ParseFlags flags, std::string *dst, RegexpStatus *status)
Definition: bloaty/third_party/re2/re2/simplify.cc:23
re2::kRegexpCharClass
@ kRegexpCharClass
Definition: bloaty/third_party/re2/re2/regexp.h:157
re2::Regexp::Parse
static Regexp * Parse(const StringPiece &s, ParseFlags flags, RegexpStatus *status)
Definition: bloaty/third_party/re2/re2/parse.cc:2200
re2::Regexp::sub
Regexp ** sub()
Definition: bloaty/third_party/re2/re2/regexp.h:327
re2::Regexp::nsub_
uint16_t nsub_
Definition: bloaty/third_party/re2/re2/regexp.h:549
re2::kRegexpAlternate
@ kRegexpAlternate
Definition: bloaty/third_party/re2/re2/regexp.h:118
min
#define min(a, b)
Definition: qsort.h:83
re2::SimplifyWalker::SimplifyCharClass
static Regexp * SimplifyCharClass(Regexp *re)
Definition: bloaty/third_party/re2/re2/simplify.cc:643
re2::CoalesceWalker::Copy
virtual Regexp * Copy(Regexp *re)
Definition: bloaty/third_party/re2/re2/simplify.cc:210
re2::Regexp::ParseFlags
ParseFlags
Definition: bloaty/third_party/re2/re2/regexp.h:278
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
google::protobuf::ERROR
static const LogLevel ERROR
Definition: bloaty/third_party/protobuf/src/google/protobuf/testing/googletest.h:70
re2::kRegexpStar
@ kRegexpStar
Definition: bloaty/third_party/re2/re2/regexp.h:121
re2::Regexp::Equal
static bool Equal(Regexp *a, Regexp *b)
Definition: bloaty/third_party/re2/re2/regexp.cc:415
re2::SimplifyWalker::operator=
SimplifyWalker & operator=(const SimplifyWalker &)=delete
re2::kRegexpAnyByte
@ kRegexpAnyByte
Definition: bloaty/third_party/re2/re2/regexp.h:139
re2::CoalesceWalker::CanCoalesce
static bool CanCoalesce(Regexp *r1, Regexp *r2)
Definition: bloaty/third_party/re2/re2/simplify.cc:296
re2::CoalesceWalker::operator=
CoalesceWalker & operator=(const CoalesceWalker &)=delete
re2::Regexp::NonGreedy
@ NonGreedy
Definition: bloaty/third_party/re2/re2/regexp.h:290
re2::CoalesceWalker::DoCoalesce
static void DoCoalesce(Regexp **r1ptr, Regexp **r2ptr)
Definition: bloaty/third_party/re2/re2/simplify.cc:336
absl::flags_internal
Definition: abseil-cpp/absl/flags/commandlineflag.h:40
re2::Regexp::Simplify
Regexp * Simplify()
Definition: bloaty/third_party/re2/re2/simplify.cc:179
re2::Regexp::Incref
Regexp * Incref()
Definition: bloaty/third_party/re2/re2/regexp.cc:89
re2::Rune
signed int Rune
Definition: bloaty/third_party/re2/util/utf.h:25
fix_build_deps.r
r
Definition: fix_build_deps.py:491
re2::Regexp::SimplifyWalker
friend class SimplifyWalker
Definition: bloaty/third_party/re2/re2/regexp.h:365
re2::CoalesceWalker
Definition: bloaty/third_party/re2/re2/simplify.cc:108
re2::CharClassBuilder::full
bool full()
Definition: bloaty/third_party/re2/re2/regexp.h:602
re2::kRegexpRepeat
@ kRegexpRepeat
Definition: bloaty/third_party/re2/re2/regexp.h:129
re2::kRegexpBeginText
@ kRegexpBeginText
Definition: bloaty/third_party/re2/re2/regexp.h:152
re2::kRegexpInternalError
@ kRegexpInternalError
Definition: bloaty/third_party/re2/re2/regexp.h:172
re2::SimplifyWalker::Concat2
static Regexp * Concat2(Regexp *re1, Regexp *re2, Regexp::ParseFlags flags)
Definition: bloaty/third_party/re2/re2/simplify.cc:563
re2::kRegexpEndLine
@ kRegexpEndLine
Definition: bloaty/third_party/re2/re2/regexp.h:144
stop
static const char stop[]
Definition: benchmark-async-pummel.c:35
re2::kRegexpCapture
@ kRegexpCapture
Definition: bloaty/third_party/re2/re2/regexp.h:133
re2::kRegexpPlus
@ kRegexpPlus
Definition: bloaty/third_party/re2/re2/regexp.h:123
re2::kRegexpNoMatch
@ kRegexpNoMatch
Definition: bloaty/third_party/re2/re2/regexp.h:104
re2::Regexp::CoalesceWalker
friend class CoalesceWalker
Definition: bloaty/third_party/re2/re2/regexp.h:364
re2::Regexp::Quest
static Regexp * Quest(Regexp *sub, ParseFlags flags)
Definition: bloaty/third_party/re2/re2/regexp.cc:230
re2::Regexp::ccb_
CharClassBuilder * ccb_
Definition: bloaty/third_party/re2/re2/regexp.h:578
subs
template_param_type subs
Definition: cxa_demangle.cpp:4906
re2::SimplifyWalker::SimplifyRepeat
static Regexp * SimplifyRepeat(Regexp *re, int min, int max, Regexp::ParseFlags parse_flags)
Definition: bloaty/third_party/re2/re2/simplify.cc:579
op
static grpc_op * op
Definition: test/core/fling/client.cc:47
re2::kRegexpQuest
@ kRegexpQuest
Definition: bloaty/third_party/re2/re2/regexp.h:125
re2::Regexp::FoldCase
@ FoldCase
Definition: bloaty/third_party/re2/re2/regexp.h:280
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
re2::Regexp::Regexp
Regexp(RegexpOp op, ParseFlags parse_flags)
Definition: bloaty/third_party/re2/re2/regexp.cc:29
re2::CoalesceWalker::CoalesceWalker
CoalesceWalker()
Definition: re2/re2/simplify.cc:108
re2::Regexp::Repeat
static Regexp * Repeat(Regexp *sub, ParseFlags flags, int min, int max)
Definition: bloaty/third_party/re2/re2/regexp.cc:306


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:13