[libcxx-commits] [PATCH] D62451: Regex backreference [1/3] Fixes backreferences for extended grammar.

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 26 10:49:42 PDT 2019


mclow.lists added inline comments.


================
Comment at: libcxx/include/regex:3552
+                        if (__val >= 1 && __val <= 9)
+                            if (__val > mark_count())
+                                __throw_regex_error<regex_constants::error_backref>();
----------------
Alternately, you could remove these two lines from this patch, and put them into D62453 (where the tests are).


================
Comment at: libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp:506
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) >= 0 && static_cast<size_t>(m.length(0)) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
----------------
Why two checks for `m.length(0)` here?

Why not just:
```
assert(static_cast<size_t>(m.length(0)) == std::char_traits<char>::length(s));
```
since you know that `length(s) > 0`
(Obviously, this applies to several places)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62451/new/

https://reviews.llvm.org/D62451





More information about the libcxx-commits mailing list