Commit Graph

121 Commits

Author SHA1 Message Date
Marshall Clow
6973bb06d9 Change a couple of '&' to addressof(). NFC
llvm-svn: 352007
2019-01-24 02:02:50 +00:00
Chandler Carruth
57b08b0944 Update more file headers across all of the LLVM projects in the monorepo
to reflect the new license. These used slightly different spellings that
defeated my regular expressions.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351648
2019-01-19 10:56:40 +00:00
Michal Gorny
a25cd0c2da [regex] Use distinct __regex_word on NetBSD
NetBSD defines character classes up to 0x2000.  Use 0x8000 as a safe
__regex_word that hopefully will not collide with other values
in the foreseeable future.

Differential Revision: https://reviews.llvm.org/D55657

llvm-svn: 349293
2018-12-16 09:18:26 +00:00
Eric Fiselier
0b485f3e91 Fix even more Clang warnings.
This patch disables shift-sign-overflow warnings for now. It also
fixes most -Wfloat-equal warnings and -Wextra-semi warnings.

llvm-svn: 343438
2018-10-01 01:59:37 +00:00
Marshall Clow
f56972e224 Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955
llvm-svn: 342073
2018-09-12 19:41:40 +00:00
Louis Dionne
954d4a2235 [libc++] Fix handling of negated character classes in regex
Summary:
This commit fixes a regression introduced in r316095, where we don't match
inverted character classes when there's no negated characrers in the []'s.

rdar://problem/43060054

Reviewers: mclow.lists, timshen, EricWF

Subscribers: christof, dexonsmith, cfe-commits

Differential Revision: https://reviews.llvm.org/D50534

llvm-svn: 340609
2018-08-24 14:10:28 +00:00
Louis Dionne
dc7200b486 [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY
Summary:
We never actually mean to always inline a function -- all the uses of
the macro I could find are actually attempts to control the visibility
of symbols. This is better described by _LIBCPP_INLINE_VISIBILITY, which
is actually always defined the same.

This change is orthogonal to the decision of what we're actually going
to do with _LIBCPP_INLINE_VISIBILITY -- it just simplifies things by
having one canonical way of doing things.

Note that this commit had originally been applied in r336369 and then
reverted in r336382 because of unforeseen problems. Both of these problems
have now been fixed.

Reviewers: EricWF, mclow.lists

Subscribers: christof, dexonsmith, erikvanderpoel

Differential Revision: https://reviews.llvm.org/D48892

llvm-svn: 336866
2018-07-11 23:14:33 +00:00
Louis Dionne
195a499d63 Revert "[libc++] Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY"
This reverts commit r336369. The commit had two problems:
1. __pbump was marked as _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY instead of
   _LIBCPP_INLINE_VISIBILITY, which lead to two symbols being added in the
   dylib and the check-cxx-abilist failing.

2. The LLDB tests started failing because they undefine
   `_LIBCPP_INLINE_VISIBILITY`. I need to figure out why they do that and
   fix the tests before we can go forward with this change.

llvm-svn: 336382
2018-07-05 18:41:50 +00:00
Louis Dionne
4a8f3f9948 [libc++] Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY
Summary:
We never actually mean to always inline a function -- all the uses of
the macro I could find are actually attempts to control the visibility
of symbols. This is better described by _LIBCPP_INLINE_VISIBILITY, which
is actually always defined the same.

This change is orthogonal to the decision of what we're actually going
to do with _LIBCPP_INLINE_VISIBILITY -- it just simplifies things by
having one canonical way of doing things.

Reviewers: EricWF

Subscribers: christof, llvm-commits, dexonsmith, erikvanderpoel, mclow.lists

Differential Revision: https://reviews.llvm.org/D48892

llvm-svn: 336369
2018-07-05 16:49:38 +00:00
Marshall Clow
edd5e29cfe Implement deduction guides for basic_regex
llvm-svn: 333050
2018-05-23 01:57:02 +00:00
Mikhail Maltsev
48c63d879b [libcxx] Correctly handle invalid regex character class names
Summary:
Currently when a regular expression contains an invalid character
class name std::regex constructors throw an std::regex_error with
std::regex_constants::error_brack code.

This patch changes the code to std::regex_constants::error_ctype and
adds a test.

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D42291

llvm-svn: 323322
2018-01-24 12:45:18 +00:00
Marshall Clow
80ebbb17a1 More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in match_results. <regex>
llvm-svn: 318375
2017-11-16 04:48:34 +00:00
Alexander Richardson
42bfedd935 Rename identifiers named __output
Summary:
In the CHERI clang compiler __output and __input are keywords and therefore
we can't compile libc++ with our compiler.

Reviewers: mclow.lists, EricWF, theraven

Reviewed By: EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D39537

llvm-svn: 318144
2017-11-14 11:14:25 +00:00
Marshall Clow
55b9e440a7 Fix an unsigned integer overflow in regex that lead to a bad memory access. Found by OSS-Fuzz
llvm-svn: 316191
2017-10-19 22:10:41 +00:00
Marshall Clow
52f0885d43 Fix UB - signed integer overflow in regex. Thanks to Tim Shen for the patch. Reviewed as https://reviews.llvm.org/D39066
llvm-svn: 316172
2017-10-19 17:39:16 +00:00
Marshall Clow
77623cb511 Fix regex bug with ^\W. Thanks to Tim Shen for the patch. Reviewed as https://reviews.llvm.org/D37955
llvm-svn: 316095
2017-10-18 16:49:22 +00:00
Marshall Clow
5a72679338 Apply D28224: 'Throw exception after too many steps' Fixes PR#20291. Thanks to Tim Shen for the patch
llvm-svn: 313056
2017-09-12 17:56:59 +00:00
Marshall Clow
52f4f72fa9 Fix a bug in regex_Iterator where it would report zero-length matches forever. Reported as http://llvm.org/PR33681. Thanks to Karen Arutyunov for the report.
llvm-svn: 307171
2017-07-05 16:37:19 +00:00
Eric Fiselier
a016efb1dc [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows
Summary:
This patch improves how libc++ handles min/max macros within the headers. Previously libc++ would undef them and emit a warning.
This patch changes libc++ to use `#pragma push_macro`  to save the macro before undefining it, and `#pragma pop_macro` to restore the macros and the end of the header.

Reviewers: mclow.lists, bcraig, compnerd, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits, krytarowski

Differential Revision: https://reviews.llvm.org/D33080

llvm-svn: 304357
2017-05-31 22:07:49 +00:00
Eric Fiselier
9f7cc58f81 Cleanup _LIBCPP_HAS_NO_<c++11-features> macro usage in regex
llvm-svn: 300627
2017-04-18 23:42:15 +00:00
Eric Fiselier
3896bf7453 Work around recent -Wshadow changes in Clang
llvm-svn: 299407
2017-04-04 01:05:59 +00:00
Eric Fiselier
5741d86d11 Replace identifiers called __out because Windows.h #defines it.
Windows is greedy and it defines the identifier `__out` as a macro.
This patch renames all conflicting libc++ identifiers in order
to correctly work on Windows.

llvm-svn: 291345
2017-01-07 11:27:06 +00:00
Eric Fiselier
e2f2d1edef [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS
The name _LIBCPP_TYPE_VIS_ONLY is no longer accurate because both
_LIBCPP_TYPE_VIS and _LIBCPP_TYPE_VIS_ONLY expand to
__attribute__((__type_visibility__)) with Clang. The only remaining difference
is that _LIBCPP_TYPE_VIS_ONLY can be applied to templates whereas
_LIBCPP_TYPE_VIS cannot (due to dllimport/dllexport not being allowed on
templates).

This patch renames _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS.

llvm-svn: 291035
2017-01-04 23:56:00 +00:00
Marshall Clow
da520dcbeb Fix bug #31387 - not checking end iterator when parsing decimal escape. Thanks to Karen for the report.
llvm-svn: 290500
2016-12-24 17:21:03 +00:00
Eric Fiselier
aec0878403 fix sign comparison warnings
llvm-svn: 290469
2016-12-24 00:24:44 +00:00
Tim Shen
e776667441 [libcxx] Make regex_match backtrack when search fails
Summary:
Fixes PR19851.
alg.re.match/ecma.pass.cpp still XFAILS on linux, but after commenting out
locale-related tests, it passes. I don't have a freebsd machine to produce a
full pass.

Reviewers: mclow.lists

Subscribers: cfe-commits, emaste

Differential Revision: https://reviews.llvm.org/D26026

llvm-svn: 285352
2016-10-27 21:40:34 +00:00
Tim Shen
abd1a6e687 [libcxx] Support std::regex_constants::match_not_null
Summary: Fixes PR21597.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D25595

llvm-svn: 284881
2016-10-21 20:41:47 +00:00
Marshall Clow
d437fa5c8c Add an _LIBCPP_NORETURN inline function named __throw_XXX for each exception type we define. They either construct and throw the exception, or abort() (if exceptions are disabled). Use these functions everywhere instead of assert()ing when exceptions are disabled. WARNING: This is a behavior change - but only with exceptions disabled. Reviewed as: https://reviews.llvm.org/D23855.
llvm-svn: 279744
2016-08-25 15:09:01 +00:00
Hubert Tong
2fdf202493 [libcxx] Add "flag" default arg: basic_regex ptr_size_flag ctor
Summary:
The synopsis in C++11 subclause 28.8 [re.regex] has:
```
basic_regex(const charT* p, size_t len,
            flag_type f = regex_constants::ECMAScript);
```

The default argument is added to libc++ by this change.

Reviewers: mclow.lists, rsmith, hubert.reinterpretcast

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D22702

Reapplies r277966.
Patch by Jason Liu!

llvm-svn: 277968
2016-08-07 22:26:04 +00:00
Hubert Tong
faf3149df6 Revert r277966. Forgot patch attribution.
llvm-svn: 277967
2016-08-07 22:23:24 +00:00
Hubert Tong
614c406f9e [libcxx] Add "flag" default arg: basic_regex ptr_size_flag ctor
Summary:
The synopsis in C++11 subclause 28.8 [re.regex] has:
```
basic_regex(const charT* p, size_t len,
            flag_type f = regex_constants::ECMAScript);
```

The default argument is added to libc++ by this change.

Reviewers: mclow.lists, rsmith, hubert.reinterpretcast

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D22702

llvm-svn: 277966
2016-08-07 22:18:33 +00:00
Hubert Tong
ac98d59802 [libcxx] basic_regex: add traits_type, string_type
Summary:
In the synopsis in C++11 subclause 28.8 [re.regex], `basic_regex` is
specified to have member typedefs `traits_type` and `string_type`. This
change adds them to libc++.

Reviewers: mclow.lists, rsmith, hubert.reinterpretcast

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D22698

Patch by Jason Liu!

llvm-svn: 277526
2016-08-02 21:34:48 +00:00
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