ldionne created this revision. ldionne added reviewers: mclow.lists, timshen. Herald added a reviewer: EricWF. Herald added subscribers: cfe-commits, dexonsmith, christof.
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 Repository: rCXX libc++ https://reviews.llvm.org/D50534 Files: libcxx/include/regex libcxx/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp Index: libcxx/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <regex> +// UNSUPPORTED: c++98, c++03 + +// Make sure that we correctly match inverted character classes. + +#include <cassert> +#include <regex> + + +int main() { + assert(std::regex_match("X", std::regex("[\\S]"))); + assert(!std::regex_match("X", std::regex("[^\\S]"))); + + assert(!std::regex_match("X", std::regex("[\\s]"))); + assert(std::regex_match("X", std::regex("[^\\s]"))); + + assert(std::regex_match("X", std::regex("[\\s\\S]"))); + assert(std::regex_match("X", std::regex("[^Y\\s]"))); + assert(!std::regex_match("X", std::regex("[^X\\s]"))); +} Index: libcxx/include/regex =================================================================== --- libcxx/include/regex +++ libcxx/include/regex @@ -2427,7 +2427,6 @@ const bool __in_neg_mask = (__neg_mask_ == 0) || __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))
Index: libcxx/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <regex> +// UNSUPPORTED: c++98, c++03 + +// Make sure that we correctly match inverted character classes. + +#include <cassert> +#include <regex> + + +int main() { + assert(std::regex_match("X", std::regex("[\\S]"))); + assert(!std::regex_match("X", std::regex("[^\\S]"))); + + assert(!std::regex_match("X", std::regex("[\\s]"))); + assert(std::regex_match("X", std::regex("[^\\s]"))); + + assert(std::regex_match("X", std::regex("[\\s\\S]"))); + assert(std::regex_match("X", std::regex("[^Y\\s]"))); + assert(!std::regex_match("X", std::regex("[^X\\s]"))); +} Index: libcxx/include/regex =================================================================== --- libcxx/include/regex +++ libcxx/include/regex @@ -2427,7 +2427,6 @@ const bool __in_neg_mask = (__neg_mask_ == 0) || __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))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits