[PATCH] D32635: [libcxx] regex: fix backreferences in forward assertions

Peter Ammon via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 28 00:02:32 PDT 2017


pammon created this revision.
Herald added a reviewer: EricWF.

In regex, forward assertions like '(?=stuff)' are implemented by
constructing a child regular expression 'stuff' and matching that.
If the child regular expression contains a backreference, this would
trip an assertion or reference the wrong capture group, because the
child was ignorant of the capture groups of its parent. For example,
/(x)(?=\1)/ would trip an assertion.

Address this by propagating submatches into the child, so that
backreferences reference the correct capture groups. This also allows us
to eliminate the mexp_ field, because the child expression shares the
entire submatch array with the parent.


https://reviews.llvm.org/D32635

Files:
  include/regex
  test/std/re/re.alg/re.alg.match/ecma.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32635.97055.patch
Type: text/x-patch
Size: 7557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170428/88cd5551/attachment.bin>


More information about the cfe-commits mailing list