[libc++] Extend check for non-ASCII characters to src/, test/ and benchmarks/

Differential Revision: https://reviews.llvm.org/D132180
This commit is contained in:
Louis Dionne 2022-08-18 17:41:13 -04:00
parent 89469df8ba
commit 355e0ce3c5
85 changed files with 364 additions and 379 deletions

View File

@ -49,8 +49,8 @@ struct AllOrders : EnumValuesAsTuple<AllOrders, Order, 7> {
// These values are arranged in such a way that they would invoke O(N^2)
// behavior on any quick sort implementation that satisifies certain conditions.
// Details are available in the following paper:
// "A Killer Adversary for Quicksort", M. D. McIlroy, SoftwarePractice &
// ExperienceVolume 29 Issue 4 April 10, 1999 pp 341344.
// "A Killer Adversary for Quicksort", M. D. McIlroy, Software-Practice &
// Experience Volume 29 Issue 4 April 10, 1999 pp 341-344.
// https://dl.acm.org/doi/10.5555/311868.311871.
template <class T>
void fillAdversarialQuickSortInput(T& V, size_t N) {

View File

@ -203,7 +203,7 @@ struct Precision<PrecisionE::Small> {
template <>
struct Precision<PrecisionE::Huge> {
// The maximum precision for a minimal sub normal long double is ±0x1p-16494.
// The maximum precision for a minimal sub normal long double is +/- 0x1p-16494.
// This value is always larger than that value forcing the trailing zero path
// to be executed.
static constexpr const char* fmt = ".17000";

View File

@ -50,7 +50,7 @@ concept HasInplaceMergeIter =
static_assert(HasInplaceMergeIter<int*, int*, int*>);
// !bidirectional_­iterator<I>
// !bidirectional_iterator<I>
static_assert(!HasInplaceMergeIter<BidirectionalIteratorNotDerivedFrom>);
static_assert(!HasInplaceMergeIter<cpp20_input_iterator<int*>>);
@ -287,7 +287,7 @@ bool test() {
// Complexity: Let N = last - first :
// - For the overloads with no ExecutionPolicy, and if enough
// additional memory is available, exactly N 1 comparisons.
// additional memory is available, exactly N - 1 comparisons.
// - Otherwise, O(NlogN) comparisons.
// In either case, twice as many projections as comparisons.
{

View File

@ -10,13 +10,13 @@
// <algorithm>
// template<random_­access_­iterator I, sentinel_­for<I> S, class Comp = ranges::less,
// template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
// class Proj = identity>
// requires sortable<I, Comp, Proj>
// constexpr I
// ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {}); // since C++20
//
// template<random_­access_­range R, class Comp = ranges::less, class Proj = identity>
// template<random_access_range R, class Comp = ranges::less, class Proj = identity>
// requires sortable<iterator_t<R>, Comp, Proj>
// constexpr borrowed_iterator_t<R>
// ranges::nth_element(R&& r, iterator_t<R> nth, Comp comp = {}, Proj proj = {}); // since C++20

View File

@ -321,7 +321,7 @@ constexpr bool test() {
// Stable ([algorithm.stable]). If [first1, last1) contains m elements that are
// equivalent to each other and [first2, last2) contains n elements that are
// equivalent to them, then all m elements from the first range are copied to the
// output range, in order, and then the final max(nm,0) elements from the second
// output range, in order, and then the final max(n-m,0) elements from the second
// range are copied to the output range, in order.
{
std::array<IntAndOrder, 3> r1{{{0, 0}, {0, 1}, {0, 2}}};

View File

@ -191,8 +191,8 @@ test_pointer_sort()
// way that they would invoke O(N^2) behavior on any quick sort implementation
// that satisifies certain conditions. Details are available in the following
// paper:
// "A Killer Adversary for Quicksort", M. D. McIlroy, SoftwarePractice &
// ExperienceVolume 29 Issue 4 April 10, 1999 pp 341344.
// "A Killer Adversary for Quicksort", M. D. McIlroy, Software-Practice &
// Experience Volume 29 Issue 4 April 10, 1999 pp 341-344.
// https://dl.acm.org/doi/10.5555/311868.311871.
struct AdversaryComparator {
AdversaryComparator(int N, std::vector<int>& input) : gas(N - 1), V(input) {

View File

@ -17,8 +17,8 @@
// constexpr span(const array<value_type, N>& arr) noexcept;
//
// Remarks: These constructors shall not participate in overload resolution unless:
// extent == dynamic_extent || N == extent is true, and
// remove_pointer_t<decltype(data(arr))>(*)[] is convertible to ElementType(*)[].
// - extent == dynamic_extent || N == extent is true, and
// - remove_pointer_t<decltype(data(arr))>(*)[] is convertible to ElementType(*)[].
//

View File

@ -13,8 +13,8 @@
// constexpr span(element_type (&arr)[N]) noexcept;
//
// Remarks: These constructors shall not participate in overload resolution unless:
// extent == dynamic_extent || N == extent is true, and
// remove_pointer_t<decltype(data(arr))>(*)[] is convertible to ElementType(*)[].
// - extent == dynamic_extent || N == extent is true, and
// - remove_pointer_t<decltype(data(arr))>(*)[] is convertible to ElementType(*)[].
//

View File

@ -15,8 +15,8 @@
// constexpr span(const array<value_type, N>& arr) noexcept;
//
// Remarks: These constructors shall not participate in overload resolution unless:
// extent == dynamic_extent || N == extent is true, and
// remove_pointer_t<decltype(data(arr))>(*)[] is convertible to ElementType(*)[].
// - extent == dynamic_extent || N == extent is true, and
// - remove_pointer_t<decltype(data(arr))>(*)[] is convertible to ElementType(*)[].
//

View File

@ -10,9 +10,9 @@
// <experimental/type_traits>
//
// struct nonesuch;
// nonesuch has no default constructor (C++17 §15.1)
// or initializer-list constructor (C++17 §11.6.4),
// and is not an aggregate (C++17 §11.6.1).
// nonesuch has no default constructor (C++17 section 15.1)
// or initializer-list constructor (C++17 section 11.6.4),
// and is not an aggregate (C++17 section 11.6.1).
#include <experimental/type_traits>

View File

@ -76,7 +76,7 @@ int main(int, char**) {
// p3: Replace each directory-separator with a preferred-separator.
// [ Note: The generic pathname grammar ([fs.path.generic]) defines
// directory-separator as one or more slashes and preferred-separators.
// end note ]
// - end note ]
{"/", "/"},
{"//", "/"},
{"///", "/"},
@ -108,7 +108,7 @@ int main(int, char**) {
{"foo/bar/./../", "foo/"},
// p6: If there is a root-directory, remove all dot-dot filenames and any
// directory-separators immediately following them. [ Note: These dot-dot
// filenames attempt to refer to nonexistent parent directories. end note ]
// filenames attempt to refer to nonexistent parent directories. - end note ]
{"/..", "/"},
{"/../", "/"},
{"/foo/../..", "/"},

View File

@ -10,7 +10,7 @@
// constexpr auto begin();
// constexpr auto begin() const
// requires input_­range<const V> &&
// requires input_range<const V> &&
// is_reference_v<range_reference_t<const V>>;
#include <cassert>
@ -119,7 +119,7 @@ constexpr bool test() {
static_assert(HasConstBegin<decltype(jv)>);
}
// !input_­range<const V>
// !input_range<const V>
{
std::ranges::join_view jv{ConstNotRange{}};
static_assert(!HasConstBegin<decltype(jv)>);

View File

@ -10,8 +10,8 @@
// constexpr iterator(iterator<!Const> i)
// requires Const &&
// convertible_­to<iterator_t<V>, OuterIter> &&
// convertible_­to<iterator_t<InnerRng>, InnerIter>;
// convertible_to<iterator_t<V>, OuterIter> &&
// convertible_to<iterator_t<InnerRng>, InnerIter>;
#include <cassert>
#include <ranges>

View File

@ -9,13 +9,13 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// constexpr iterator& operator--();
// requires ref-is-glvalue && bidirectional_­range<Base> &&
// bidirectional_­range<range_reference_t<Base>> &&
// common_­range<range_reference_t<Base>>;
// requires ref-is-glvalue && bidirectional_range<Base> &&
// bidirectional_range<range_reference_t<Base>> &&
// common_range<range_reference_t<Base>>;
// constexpr iterator operator--(int);
// requires ref-is-glvalue && bidirectional_­range<Base> &&
// bidirectional_­range<range_reference_t<Base>> &&
// common_­range<range_reference_t<Base>>;
// requires ref-is-glvalue && bidirectional_range<Base> &&
// bidirectional_range<range_reference_t<Base>> &&
// common_range<range_reference_t<Base>>;
#include <cassert>
#include <ranges>
@ -124,7 +124,7 @@ constexpr bool test() {
}
{
// !bidirectional_­range<Base>
// !bidirectional_range<Base>
BidiCommonInner inners[2] = {buffer[0], buffer[1]};
SimpleForwardCommonOuter<BidiCommonInner> outer{inners};
std::ranges::join_view jv(outer);
@ -132,7 +132,7 @@ constexpr bool test() {
}
{
// !bidirectional_­range<range_reference_t<Base>>
// !bidirectional_range<range_reference_t<Base>>
ForwardCommonInner inners[2] = {buffer[0], buffer[1]};
std::ranges::join_view jv(inners);
noDecrementTest(jv);
@ -141,7 +141,7 @@ constexpr bool test() {
{
// LWG3313 `join_view::iterator::operator--` is incorrectly constrained
// `join_view::iterator` should not have `operator--` if
// !common_­range<range_reference_t<Base>>
// !common_range<range_reference_t<Base>>
BidiNonCommonInner inners[2] = {buffer[0], buffer[1]};
std::ranges::join_view jv(inners);
auto iter = jv.begin();

View File

@ -11,7 +11,7 @@
// constexpr iterator& operator++();
// constexpr void operator++(int);
// constexpr iterator operator++(int)
// requires ref-is-glvalue && forward_­range<Base> &&
// requires ref-is-glvalue && forward_range<Base> &&
// forward_range<range_reference_t<Base>>;
#include <cassert>
@ -186,7 +186,7 @@ constexpr bool test() {
}
{
// !forward_­range<Base>
// !forward_range<Base>
BufferView<int*> inners[2] = {buffer1[0], buffer1[1]};
using Outer = SimpleInputCommonOuter<BufferView<int*>>;
std::ranges::join_view jv{Outer(inners)};

View File

@ -9,7 +9,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// constexpr sentinel(sentinel<!Const> s);
// requires Const && convertible_­to<sentinel_t<V>, sentinel_t<Base>>;
// requires Const && convertible_to<sentinel_t<V>, sentinel_t<Base>>;
#include <cassert>
#include <ranges>

View File

@ -16,7 +16,7 @@
// x - y;
// All the arithmetic operators have the constraint `requires all-random-access<Const, Views...>;`,
// except `operator-(x, y)` which instead has the constraint
// `requires (sized_­sentinel_­for<iterator_t<maybe-const<Const, Views>>,
// `requires (sized_sentinel_for<iterator_t<maybe-const<Const, Views>>,
// iterator_t<maybe-const<Const, Views>>> && ...);`
#include <ranges>

View File

@ -9,7 +9,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// friend constexpr bool operator==(const iterator& x, const iterator& y)
// requires (equality_­comparable<iterator_t<maybe-const<Const, Views>>> && ...);
// requires (equality_comparable<iterator_t<maybe-const<Const, Views>>> && ...);
// friend constexpr bool operator<(const iterator& x, const iterator& y)
// requires all-random-access<Const, Views...>;
// friend constexpr bool operator>(const iterator& x, const iterator& y)
@ -20,7 +20,7 @@
// requires all-random-access<Const, Views...>;
// friend constexpr auto operator<=>(const iterator& x, const iterator& y)
// requires all-random-access<Const, Views...> &&
// (three_­way_­comparable<iterator_t<maybe-const<Const, Views>>> && ...);
// (three_way_comparable<iterator_t<maybe-const<Const, Views>>> && ...);
#include <ranges>
#include <compare>

View File

@ -9,7 +9,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// constexpr iterator(iterator<!Const> i)
// requires Const && (convertible_­to<iterator_t<Views>,
// requires Const && (convertible_to<iterator_t<Views>,
// iterator_t<maybe-const<Const, Views>>> && ...);
#include <ranges>

View File

@ -9,7 +9,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// friend constexpr void iter_swap(const iterator& l, const iterator& r) noexcept(see below)
// requires (indirectly_­swappable<iterator_t<maybe-const<Const, Views>>> && ...);
// requires (indirectly_swappable<iterator_t<maybe-const<Const, Views>>> && ...);
#include <array>
#include <cassert>

View File

@ -9,10 +9,10 @@
// <regex>
// UNSUPPORTED: c++03, c++11, c++14
// template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
// vector(InputIterator, InputIterator, Allocator = Allocator())
// -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
//
// template<class ForwardIterator>
// basic_regex(ForwardIterator, ForwardIterator,
// regex_constants::syntax_option_type = regex_constants::ECMAScript)
// -> basic_regex<typename iterator_traits<ForwardIterator>::value_type>;
#include <regex>
#include <string>
@ -36,8 +36,5 @@ int main(int, char**)
std::basic_regex re(23.0, 34.0, std::regex_constants::basic); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_regex'}}
}
// Test the implicit deduction guides
return 0;
}

View File

@ -17,7 +17,7 @@
// Returns: If x.ok() == true and y.ok() == true, returns a value m in the range
// [months{0}, months{11}] satisfying y + m == x.
// Otherwise the value returned is unspecified.
// [Example: January - February == months{11}. end example]
// [Example: January - February == months{11}. -end example]
#include <chrono>
#include <type_traits>

View File

@ -20,8 +20,8 @@
// [Note: Given a divisor of 12, Euclidean division truncates towards negative infinity
// and always produces a remainder in the range of [0, 11].
// Assuming no overflow in the signed summation, this operation results in a month
// holding a value in the range [1, 12] even if !x.ok(). end note]
// [Example: February + months{11} == January. end example]
// holding a value in the range [1, 12] even if !x.ok(). -end note]
// [Example: February + months{11} == January. -end example]

View File

@ -30,7 +30,6 @@
// operator/(const day& d, int m) noexcept;
// Returns: month(m) / d.
#include <chrono>
#include <type_traits>
#include <cassert>

View File

@ -28,7 +28,7 @@
//
//
// [Note: A month_day_last object can be constructed using the expression m/last or last/m,
// where m is an expression of type month. end note]
// where m is an expression of type month. - end note]
// [Example:
// constexpr auto mdl = February/last; // mdl is the last day of February of an as yet unspecified year
// static_assert(mdl.month() == February);

View File

@ -26,16 +26,12 @@
// operator/(const weekday_indexed& wdi, int m) noexcept;
// Returns: month(m) / wdi.
//
// [Example:
// constexpr auto mwd = February/Tuesday[3]; // mwd is the third Tuesday of February of an as yet unspecified year
// static_assert(mwd.month() == February);
// static_assert(mwd.weekday_indexed() == Tuesday[3]);
// —end example]
// -end example]
#include <chrono>
#include <type_traits>

View File

@ -26,9 +26,6 @@
// operator/(const weekday_last& wdl, int m) noexcept;
// Returns: month(m) / wdl.
#include <chrono>
#include <type_traits>
#include <cassert>

View File

@ -16,8 +16,6 @@
// constexpr year_month operator/(const year& y, int m) noexcept;
// Returns: y / month(m).
#include <chrono>
#include <type_traits>
#include <cassert>

View File

@ -34,7 +34,6 @@
// operator/(const month_day& md, int y) noexcept;
// Returns: year(y) / md.
#include <chrono>
#include <type_traits>
#include <cassert>

View File

@ -30,7 +30,6 @@
// operator/(const month_day_last& mdl, int y) noexcept;
// Returns: year(y) / mdl.
#include <chrono>
#include <type_traits>
#include <cassert>

View File

@ -30,8 +30,6 @@
// operator/(const month_weekday_last& mwdl, int y) noexcept;
// Returns: year(y) / mwdl.
#include <chrono>
#include <type_traits>
#include <cassert>

View File

@ -21,7 +21,7 @@
//
// [Example:
// If dp represents 1970-01-01, the constructed weekday represents Thursday by storing 4 in wd_.
// end example]
// -end example]
#include <chrono>
#include <type_traits>

View File

@ -21,7 +21,7 @@
//
// [Example:
// If dp represents 1970-01-01, the constructed weekday represents Thursday by storing 4 in wd_.
// end example]
// -end example]
#include <chrono>
#include <type_traits>

View File

@ -17,7 +17,7 @@
// Returns: If x.ok() == true and y.ok() == true, returns a value d in the range
// [days{0}, days{6}] satisfying y + d == x.
// Otherwise the value returned is unspecified.
// [Example: Sunday - Monday == days{6}. end example]
// [Example: Sunday - Monday == days{6}. -end example]
#include <chrono>
#include <type_traits>

View File

@ -20,10 +20,8 @@
// [Note: Given a divisor of 12, Euclidean division truncates towards negative infinity
// and always produces a remainder in the range of [0, 6].
// Assuming no overflow in the signed summation, this operation results in a weekday
// holding a value in the range [0, 6] even if !x.ok(). —end note]
// [Example: Monday + days{6} == Sunday. —end example]
// holding a value in the range [0, 6] even if !x.ok(). -end note]
// [Example: Monday + days{6} == Sunday. -end example]
#include <chrono>
#include <type_traits>

View File

@ -17,7 +17,7 @@
// Returns: If x.ok() == true and y.ok() == true, returns a value m in the range
// [years{0}, years{11}] satisfying y + m == x.
// Otherwise the value returned is unspecified.
// [Example: January - February == years{11}. end example]
// [Example: January - February == years{11}. -end example]
#include <chrono>
#include <type_traits>

View File

@ -27,7 +27,7 @@
// static_assert(year_month_day{local_days{2017y/January/0}} == 2016y/December/31);
// static_assert(year_month_day{local_days{2017y/January/31}} == 2017y/January/31);
// static_assert(year_month_day{local_days{2017y/January/32}} == 2017y/February/1);
// end example]
// -end example]
#include <chrono>
#include <type_traits>

View File

@ -27,7 +27,7 @@
// static_assert(year_month_day{sys_days{2017y/January/0}} == 2016y/December/31);
// static_assert(year_month_day{sys_days{2017y/January/31}} == 2017y/January/31);
// static_assert(year_month_day{sys_days{2017y/January/32}} == 2017y/February/1);
// end example]
// -end example]
#include <chrono>
#include <type_traits>

View File

@ -17,8 +17,8 @@
// [Example:
// sys_seconds{sys_days{1970y/January/1}}.time_since_epoch() is 0s.
// sys_seconds{sys_days{2000y/January/1}}.time_since_epoch() is 946684800s, which is 10957 * 86400s.
// end example]
// sys_seconds{sys_days{2000y/January/1}}.time_since_epoch() is 946'684'800s, which is 10'957 * 86'400s.
// - end example]
#include <chrono>

View File

@ -16,8 +16,8 @@
// [Example:
// sys_seconds{sys_days{1970y/January/1}}.time_since_epoch() is 0s.
// sys_seconds{sys_days{2000y/January/1}}.time_since_epoch() is 946684800s, which is 10957 * 86400s.
// end example]
// sys_seconds{sys_days{2000y/January/1}}.time_since_epoch() is 946'684'800s, which is 10'957 * 86'400s.
// - end example]
#include <chrono>

View File

@ -35,7 +35,7 @@
// template <class T, class D>
// bool operator>=(nullptr_t, const unique_ptr<T, D>& y);
// template<class T, class D>
// requires three_­way_­comparable<typename unique_ptr<T, D>::pointer>
// requires three_way_comparable<typename unique_ptr<T, D>::pointer>
// constexpr compare_three_way_result_t<typename unique_ptr<T, D>::pointer>
// operator<=>(const unique_ptr<T, D>& x, nullptr_t); // C++20

View File

@ -11,8 +11,7 @@
// template <class... Types>
// template <class Alloc, class U1, class U2>
// constexpr explicit(see below)
// tuple<Types...>::tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&
// u);
// tuple<Types...>::tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>& u);
// Constraints:
// - sizeof...(Types) is 2 and

View File

@ -328,20 +328,20 @@ private:
/// This class generates the following tree:
///
/// static_test_env
/// ├── bad_symlink -> dne
/// ├── dir1
/// │   ├── dir2
/// │   │   ├── afile3
/// │   │   ├── dir3
/// │   │   │   └── file5
/// │   │   ├── file4
/// │   │   └── symlink_to_dir3 -> dir3
/// │   ├── file1
/// │   └── file2
/// ├── empty_file
/// ├── non_empty_file
/// ├── symlink_to_dir -> dir1
/// └── symlink_to_empty_file -> empty_file
/// |-- bad_symlink -> dne
/// |-- dir1
/// | |-- dir2
/// | | |-- afile3
/// | | |-- dir3
/// | | | `-- file5
/// | | |-- file4
/// | | `-- symlink_to_dir3 -> dir3
/// | `-- file1
/// | `-- file2
/// |-- empty_file
/// |-- non_empty_file
/// |-- symlink_to_dir -> dir1
/// `-- symlink_to_empty_file -> empty_file
///
class static_test_env {
scoped_test_env env_;

View File

@ -185,7 +185,12 @@ check-generated-output)
# Reject patches that introduce non-ASCII characters or hard tabs.
# Depends on LC_COLLATE set at the top of this script.
! grep -rn '[^ -~]' libcxx/include/ || false
! grep -rn '[^ -~]' libcxx/include libcxx/src libcxx/test libcxx/benchmarks \
--exclude '*.dat' \
--exclude 'std_format_spec_string_unicode.bench.cpp' \
--exclude 'grep.pass.cpp' \
--exclude 'locale-specific_form.pass.cpp' \
--exclude 'format_tests.h' || false
# Reject code with trailing whitespace
! grep -rn '[[:blank:]]$' libcxx/include libcxx/src libcxx/test libcxx/benchmarks || false