[PATCH] D42291: [libcxx] Correctly handle invalid regex character class names
Mikhail Maltsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 24 04:47:54 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323322: [libcxx] Correctly handle invalid regex character class names (authored by miyuki, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D42291?vs=130584&id=131226#toc
Repository:
rL LLVM
https://reviews.llvm.org/D42291
Files:
libcxx/trunk/include/regex
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_ctype.pass.cpp
Index: libcxx/trunk/include/regex
===================================================================
--- libcxx/trunk/include/regex
+++ libcxx/trunk/include/regex
@@ -4013,7 +4013,7 @@
char_class_type __class_type =
__traits_.lookup_classname(__first, __temp, __flags_ & icase);
if (__class_type == 0)
- __throw_regex_error<regex_constants::error_brack>();
+ __throw_regex_error<regex_constants::error_ctype>();
__ml->__add_class(__class_type);
__first = _VSTD::next(__temp, 2);
return __first;
Index: libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_ctype.pass.cpp
===================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_ctype.pass.cpp
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_ctype.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: libcpp-no-exceptions
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+// basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+#include "test_macros.h"
+
+static bool error_ctype_thrown(const char *pat)
+{
+ bool result = false;
+ try {
+ std::regex re(pat);
+ } catch (const std::regex_error &ex) {
+ result = (ex.code() == std::regex_constants::error_ctype);
+ }
+ return result;
+}
+
+int main()
+{
+ assert(error_ctype_thrown("[[::]]"));
+ assert(error_ctype_thrown("[[:error:]]"));
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42291.131226.patch
Type: text/x-patch
Size: 1893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180124/8f9b734f/attachment.bin>
More information about the llvm-commits
mailing list