Commit Graph

89 Commits

Author SHA1 Message Date
Daniel Sanders 4788179a2c [libcxx] Fix definition of regex_traits::__regex_word on big-endian glibc systems
Summary:
On glibc, the bits used for the various character classes is endian dependant
(see _ISbit() in ctypes.h) but __regex_word does not account for this and uses
a spare bit that isn't spare on big-endian. On big-endian, it overlaps with the
bit for graphic characters which causes '-', '@', etc. to be considered a word
character.

Fixed this by defining the value using _ISbit(15) on MIPS glibc systems. We've
restricted this to MIPS for now to avoid the risk of introducing failures in
other targets.

Fixes PR26476.

Reviewers: hans, mclow.lists

Subscribers: dsanders, cfe-commits

Differential Revision: http://reviews.llvm.org/D17132

llvm-svn: 261088
2016-02-17 13:16:31 +00:00
Duncan P. N. Exon Smith f42ef3efca re.results.form: Format out-of-range subexpression references as null
Rather than crashing in match_results::format() when a reference to a
marked subexpression is out of range, format the subexpression as empty
(i.e., replace it with an empty string).  Note that
match_results::operator[]() has a range-check and returns a null match
in this case, so this just re-uses that logic.

llvm-svn: 259682
2016-02-03 19:30:20 +00:00
Marshall Clow b414b2f54b Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed as http://reviews.llvm.org/D16262
llvm-svn: 258107
2016-01-19 00:50:37 +00:00
Evgeniy Stepanov 906c872db9 Cleanup: move visibility/linkage attributes to the first declaration.
This change moves visibility attributes from out-of-class method
definitions to in-class declaration. This is needed for a switch to
attribute((internal_linkage)) (see http://reviews.llvm.org/D13925)
which can only appear on the first declaration.

This change does not touch istream/ostream/streambuf. They are
handled separately in http://reviews.llvm.org/D14409.

llvm-svn: 252385
2015-11-07 01:22:13 +00:00
Marshall Clow 550dfe79ca Fix a crasher found by libFuzzer
llvm-svn: 245849
2015-08-24 15:57:09 +00:00
Marshall Clow 05ddbffbf3 Make regex and any assert when they should throw an exception _but_ the user has decreed 'no exceptions'. This matches the behavior of string and vector
llvm-svn: 245239
2015-08-17 21:14:16 +00:00
Marshall Clow bcbc37d8a1 Consolidate a bunch of #ifdef _LIBCPP_NO_EXCEPTIONS .. #endif blocks into a single template function. NFC
llvm-svn: 243415
2015-07-28 13:30:47 +00:00
Marshall Clow 983d178108 Detect and throw on a class of bad regexes that we mistakenly accepted before. Thanks to Trevor Smigiel for the report
llvm-svn: 243030
2015-07-23 18:27:51 +00:00
Eric Fiselier b50f8f9ee7 Fix initializer list order in <regex> to be correct
llvm-svn: 242864
2015-07-22 01:29:41 +00:00
Eric Fiselier 818139da59 Remove unused typedefs in random and regex
llvm-svn: 242628
2015-07-18 22:57:14 +00:00
Marshall Clow 8fa8e5fc74 Add code to honor the match_not_bol and match_not_eol regex flats. Fixes PR#22651. Thanks to Jim Porter for the report and suggested fix.
llvm-svn: 232733
2015-03-19 17:05:59 +00:00
Marshall Clow 538fec0e59 Fix for PR22061 by K-ballo
llvm-svn: 227384
2015-01-28 22:22:35 +00:00
Marshall Clow 9db9069cf3 Make regex::assign not clobber the regex in case of failure. Fixes PR#22213
llvm-svn: 225799
2015-01-13 16:49:52 +00:00
Marshall Clow b04058e8c1 Implement LWG 2217 - operator==(sub_match, string) slices on embedded '\0's
llvm-svn: 224292
2014-12-15 23:57:56 +00:00
Dan Albert 15c010a37e Base regex code on char_class_type.
__get_classname() and __bracket_expression were assuming that
char_class_type was ctype_base::mask rather than using
regex_traits<_CharT>::char_class_type.

This change allows char_class_type to be defined to something other than
ctype_base::mask so that the implementation will still work for
platforms with an 8-bit ctype mask (such as Android and OpenBSD).

llvm-svn: 214201
2014-07-29 19:23:39 +00:00
Marshall Clow 9393b5113b Fix Bug 19678 - libc++ does not correctly handle the regex: '[^\0]*'
llvm-svn: 209307
2014-05-21 16:29:50 +00:00
Marshall Clow 16da324051 Implement LWG issue 2306: match_results::reference should be value_type&, not const value_type&. This is a general move by the LWG to have the reference type of read-only containers be a non-const reference; however, there are no methods that return a non-const reference to a match_result entry, so there's no worries about getting a non-const reference to a constant object.
llvm-svn: 202214
2014-02-26 01:56:31 +00:00
Marshall Clow 7d35711187 Implement LWG Issues #2329 and #2332 - disallow iterators into temporary regexes and regexes into temporary strings
llvm-svn: 201717
2014-02-19 21:21:11 +00:00
Marshall Clow 9aafa898f9 Update __parse_DUP_COUNT and __parse_BACKREF to use the traits class to recognize digits. Fixes PR18514
llvm-svn: 199541
2014-01-18 03:40:03 +00:00
Marshall Clow 54f6bd59f5 Fix a bug in regex_token_iterator's copy constructor. Caught by Bob Wilson.
llvm-svn: 199122
2014-01-13 17:47:08 +00:00
Marshall Clow 79b0fee3c6 Fix PR18404 - 'Bug in regex_token_iterator::operator++(int) implementation'. Enhance the tests for regex_token_iterator and regex_iterator.
llvm-svn: 198878
2014-01-09 18:25:57 +00:00
Marshall Clow e604469e5c Patch by GM: apparently '__value' (two underscores) is a special name in Visual Studio, so rename the private method in <regex> with that name. GM's patch used '___value' (three underscores), but I changed that to '__regex_traits_value' because I've been burned in the past by identifiers that appear identical but are not.
llvm-svn: 193087
2013-10-21 15:43:25 +00:00
Howard Hinnant fc88dbd298 Debug mode for string. This commit also marks the first time libc++ debug-mode has found a bug (found one in regex). Had to play with extern templates a bit to get this to work since string is heavily used within libc++.dylib.
llvm-svn: 189114
2013-08-23 17:37:05 +00:00
Howard Hinnant f0544c2086 Nico Rieck: this patch series fixes visibility issues on Windows as explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>.
llvm-svn: 188192
2013-08-12 18:38:34 +00:00
Howard Hinnant 7491a16031 Bill Fisher: This patch fixes a bug where std::regex in ECMAScript mode was ignoring capture groups inside lookahead assertions.
For example, matching /(?=(a))(a)/ to "a" should yield two captures: \1 = "a", \2 = "a"

llvm-svn: 186954
2013-07-23 16:18:04 +00:00
Howard Hinnant 22161401df Bill Fisher: This patch fixes an ill-formed comparison when parsing control escapes, e.g. "\cA\ca". The code will now throw an error_escape exception for invalid control sequences like "\c:" or "\c".
I've added the test cases to bad_escape.pass.cpp.

llvm-svn: 186335
2013-07-15 18:21:11 +00:00
Howard Hinnant c815a4e297 Bill Fisher: This patch fixes a less likely case where '\b' can back up into invalid memory, when driven by a regex_iterator (for case 1, see r185273 or http://llvm.org/bugs/show_bug.cgi?id=16240)
The attached test program also supplies a test for the case 1 fix in r185273.

llvm-svn: 186089
2013-07-11 15:32:55 +00:00
Howard Hinnant dbdeb153d8 Bill Fisher: This patch fixes a bug where regex_iterator doesn't indicate when it's restarting in the middle of a string. This bug causes /^a/ to match in the middle of the string "aaaaaaa", during iteration.
My patch uses  to communicate when  is false.

llvm-svn: 185950
2013-07-09 17:29:09 +00:00
Howard Hinnant 43bbdd29de Bill Fisher: This patch fixes a bug where the regex parser doesn't advance the pointer after reading the third character of an octal escape (in awk mode).
That is, regex{"\141", awk} results in the regular expression /a1/ instead of just /a/.

llvm-svn: 185449
2013-07-02 17:43:31 +00:00
Howard Hinnant 660f2ae422 Prevent '\b' from backing up into invalid memory. Fixes http://llvm.org/bugs/show_bug.cgi?id=16240. Sorry, I can not think of a good test case for this one, except by running valgrind as reported in the bug.
llvm-svn: 185273
2013-06-29 23:45:43 +00:00
Howard Hinnant 3f75953d82 Provide missing '{' in parsing extended quoted characters. This fixes http://llvm.org/bugs/show_bug.cgi?id=16135
llvm-svn: 185211
2013-06-28 20:31:05 +00:00
Howard Hinnant 8d1e822432 William Fisher: A bug in __lookahead::exec causes /(?=^)b/ to match ab. When makes a recursive call to , it passes true for the value of . This causes a beginning-of-line anchor (^) inside a lookahead assertion to match anywhere in the text. This fixes http://llvm.org/bugs/show_bug.cgi?id=11118
llvm-svn: 185196
2013-06-28 19:11:23 +00:00
Howard Hinnant 21246e3314 Bill Fisher: Fix for failing to throw an exception in regex when parsing an invalid escape sequence. This fixes http://llvm.org/bugs/show_bug.cgi?id=16023
llvm-svn: 185192
2013-06-28 18:57:30 +00:00
Marshall Clow 1c2c986796 Fix undefined behavior in syntax_option_type::operator~ and match_flag_type::operator./a.out Found by UBSan
llvm-svn: 177693
2013-03-22 02:13:55 +00:00
Howard Hinnant c60bf548c5 Albert Wong: definition for regex_traits<_CharT>::__regex_word.
llvm-svn: 176640
2013-03-07 19:38:08 +00:00
Howard Hinnant 6e41256f68 No functionality change at this time. I've split _LIBCPP_VISIBLE up into two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute.
llvm-svn: 176593
2013-03-06 23:30:19 +00:00
Howard Hinnant 16694b5df5 Zhang Xiongpang: Add definitions for const data members. Fixes http://llvm.org/bugs/show_bug.cgi?id=14585.
llvm-svn: 170026
2012-12-12 21:14:28 +00:00
Argyrios Kyrtzidis 88db3171dd Don't neglect to "return *this".
llvm-svn: 165860
2012-10-13 02:03:45 +00:00
Howard Hinnant aeb85680fb Dimitry Andric: many visibility fixes. Howard: Much appreciated. Can you send me a patch to CREDITS.TXT?
llvm-svn: 163862
2012-09-14 00:39:16 +00:00
Howard Hinnant 42be98ab54 noexcept and constexpr applied to <regex>.
llvm-svn: 160594
2012-07-21 01:31:58 +00:00
Howard Hinnant c206366fd7 Quash a whole bunch of warnings
llvm-svn: 145624
2011-12-01 20:21:04 +00:00
Howard Hinnant c003db1fca Further macro protection by replacing _[A-Z] with _[A-Z]p
llvm-svn: 145410
2011-11-29 18:15:50 +00:00
Howard Hinnant ab4f438239 Add protection from min/max macros
llvm-svn: 145407
2011-11-29 16:45:27 +00:00
Howard Hinnant 073458b1ab Windows support by Ruben Van Boxem.
llvm-svn: 142235
2011-10-17 20:05:10 +00:00
Howard Hinnant 2a4812fd04 Fix <rdar://problem/10255403> match_results::begin() is off by one
llvm-svn: 141494
2011-10-08 14:36:16 +00:00
Howard Hinnant 54976f2619 Fixed PR10574: http://llvm.org/bugs/show_bug.cgi?id=10574
llvm-svn: 137522
2011-08-12 21:56:02 +00:00
Howard Hinnant ce48a1137d _STD -> _VSTD to avoid macro clash on windows
llvm-svn: 134190
2011-06-30 21:18:19 +00:00
Howard Hinnant ce53420e37 Provide names for template and function parameters in forward declarations. The purpose is to aid automated documentation tools.
llvm-svn: 133008
2011-06-14 19:58:17 +00:00
Howard Hinnant 382600ff97 Jonathan Sauer found a bug in the way ^ was handled
llvm-svn: 128350
2011-03-26 20:02:27 +00:00
Howard Hinnant a0fe8c436e Chris Jefferson noted many places where function calls needed to be qualified (thanks Chris).
llvm-svn: 125510
2011-02-14 19:12:38 +00:00