diff options
| author | Louis Dionne <ldionne@apple.com> | 2018-08-24 14:10:28 +0000 |
|---|---|---|
| committer | Louis Dionne <ldionne@apple.com> | 2018-08-24 14:10:28 +0000 |
| commit | 954d4a2235865af388f3d8ce4dc7793ba4703139 (patch) | |
| tree | 62359fe7503edc71bcb55adf3b726b250e420c1d /libcxx/include/regex | |
| parent | 616ef1863faef8dedf2e6bfbaee7569d84f11e35 (diff) | |
| download | bcm5719-llvm-954d4a2235865af388f3d8ce4dc7793ba4703139.tar.gz bcm5719-llvm-954d4a2235865af388f3d8ce4dc7793ba4703139.zip | |
[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
Diffstat (limited to 'libcxx/include/regex')
| -rw-r--r-- | libcxx/include/regex | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/libcxx/include/regex b/libcxx/include/regex index 84aacc029ed..dcdb14af9af 100644 --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -2414,20 +2414,17 @@ __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const goto __exit; } } - // set of "__found" chars = + // When there's at least one of __neg_chars_ and __neg_mask_, the set + // of "__found" chars is // union(complement(union(__neg_chars_, __neg_mask_)), // other cases...) // - // __neg_chars_ and __neg_mask_'d better be handled together, as there - // are no short circuit opportunities. - // - // In addition, when __neg_mask_/__neg_chars_ is empty, they should be - // treated as all ones/all chars. + // It doesn't make sense to check this when there are no __neg_chars_ + // and no __neg_mask_. + if (!(__neg_mask_ == 0 && __neg_chars_.empty())) { - const bool __in_neg_mask = (__neg_mask_ == 0) || - __traits_.isctype(__ch, __neg_mask_); + const bool __in_neg_mask = __traits_.isctype(__ch, __neg_mask_); const bool __in_neg_chars = - __neg_chars_.empty() || std::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) != __neg_chars_.end(); if (!(__in_neg_mask || __in_neg_chars)) |

