[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-21 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284881: [libcxx] Support 
std::regex_constants::match_not_null (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D25595?vs=75186&id=75480#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25595

Files:
  libcxx/trunk/include/regex
  libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp


Index: libcxx/trunk/include/regex
===
--- libcxx/trunk/include/regex
+++ libcxx/trunk/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5703,6 +5715,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;
Index: libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
===
--- libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
+++ libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches 
and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+
+  assert(!std::regex_match("", m, std::regex("a*"),
+   std::regex_constants::match_not_null));
+  assert(!std::regex_match("", m, std::regex("a*", std::regex::extended),
+   std::regex_constants::match_not_null));
+  assert(!std::regex_match(
+  "", m,
+  std::regex("a*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+
+  return 0;
+}


Index: libcxx/trunk/include/regex
===
--- libcxx/trunk/include/regex
+++ libcxx/trunk/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_no

[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-19 Thread Marshall Clow via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM.  Thanks!


https://reviews.llvm.org/D25595



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-19 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 75186.
timshen added a comment.

Add tests for regex_match.


https://reviews.llvm.org/D25595

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp


Index: libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches 
and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+
+  assert(!std::regex_match("", m, std::regex("a*"),
+   std::regex_constants::match_not_null));
+  assert(!std::regex_match("", m, std::regex("a*", std::regex::extended),
+   std::regex_constants::match_not_null));
+  assert(!std::regex_match(
+  "", m,
+  std::regex("a*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+
+  return 0;
+}
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5703,6 +5715,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;


Index: libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_n

[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-19 Thread Tim Shen via cfe-commits
timshen added a comment.

In https://reviews.llvm.org/D25595#574364, @mclow.lists wrote:

> Do we need to test calling `regex_match` with `match_not_null`?
>  If not, then I think this is good to go.


Done.

> Do you have commit access, or would you rather I committed it?

Yes, I have the commit access.

Thanks for reviewing!


https://reviews.llvm.org/D25595



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-19 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

Do we need to test calling `regex_match` with `match_not_null`?
If not, then I think this is good to go.

Do you have commit access, or would you rather I committed it?


https://reviews.llvm.org/D25595



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-19 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D25595#572043, @timshen wrote:

> BTW, `re.const/re.matchflag/match_flag_type.pass.cpp` contains match_not_bow, 
> but it doesn't actually test the functionality.


It tests that it exists and that it has a sane value - which are a good things 
to test.
But there are no tests that show that when passed to `regex_search` it does the 
right thing.


https://reviews.llvm.org/D25595



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-17 Thread Tim Shen via cfe-commits
timshen added a comment.

In https://reviews.llvm.org/D25595#571171, @mclow.lists wrote:

> I like the fix. :-)
>
> However, I think that the test, rather than going in a bug specific file 
> (pr21597.pass.cpp), should be added to the existing tests - where it should 
> have been in the first place.  (If this test had been there in the first 
> place, we would have realized that this feature didn't work)


Agree.

> Also, putting the test in as 
> `test/std/re/re.const/re.matchflag/match_not_null.pass.cpp` might cause 
> someone to look at the contents of that directory and say "Crap! We're 
> missing tests for `match_not_bow`, `match_not_eow`, `match_any`, 
> `match_continuous` and `match_prev_avail` as well" (and probably others).

Making people realize the fact that we don't have tests for `match_not_bow`, 
etc. isn't bad, is it? Hopefully it motivates people to add tests. So I'll move 
the file to `re.const/re.matchflag/match_not_null.pass.cpp` for now.

BTW, `re.const/re.matchflag/match_flag_type.pass.cpp` contains match_not_bow, 
but it doesn't actually test the functionality.


https://reviews.llvm.org/D25595



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-17 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 74894.
timshen marked an inline comment as done.
timshen added a comment.

Updated file location and documentation.


https://reviews.llvm.org/D25595

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp


Index: libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches 
and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+}
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5703,6 +5715,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;


Index: libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+}
Index: libcxx/include/regex

[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-17 Thread Marshall Clow via cfe-commits
mclow.lists added inline comments.



Comment at: libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp:12
+
+// template 
+// bool

Rather than this comment about `regex_search`, there should be a comment about 
`match_not_null`, which is really what we're testing here.

Something like:
// match_not_null:
// The expression shall not match an empty sequence.



https://reviews.llvm.org/D25595



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-15 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

I like the fix. :-)

However, I think that the test, rather than going in a bug specific file 
(pr21597.pass.cpp), should be added to the existing tests - where it should 
have been in the first place.  (If this test had been there in the first place, 
we would have realized that this feature didn't work)

Also, putting the test in as 
`test/std/re/re.const/re.matchflag/match_not_null.pass.cpp` might cause someone 
to look at the contents of that directory and say "Crap! We're missing tests 
for `match_not_bow`, `match_not_eow`, `match_any`, `match_continuous` and 
`match_prev_avail` as well" (and probably others).


https://reviews.llvm.org/D25595



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-14 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added reviewers: mclow.lists, EricWF.
timshen added a subscriber: cfe-commits.

Fixes PR21597.


https://reviews.llvm.org/D25595

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp


Index: libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
@@ -0,0 +1,39 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//  match_results& m,
+//  const basic_regex& e,
+//  regex_constants::match_flag_type flags = 
regex_constants::match_default);
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches 
and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+}
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5703,6 +5715,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;


Index: libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
@@ -0,0 +1,39 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//  match_results& m,
+//  const basic_regex& e,
+//  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::re