Skip to content

Commit

Permalink
Pretty clang-format find/version check messages
Browse files Browse the repository at this point in the history
Let's make these more consistent with the messages for `find_package(Python)` and the assembler. If nothing else, showing the path to the found clang-format may help folks who are finding the wrong version.

Remove extraneous `element_type` from `ContiguousIterator`

And while we're here, use `value_type` and `difference_type` where appropriate so we can easily see which `int` is which.

Remove unused include from `P2163R3_invoke_r`

This test doesn't need `is_permissive.hpp` after microsoft#4914.

Simplify `construct_at` constraint

Investigate a couple of libc++ failures

Add some missing `#endif` comments

These were incorrectly removed by microsoft#4944.
  • Loading branch information
CaseyCarter committed Sep 10, 2024
1 parent ab20dbd commit cff3446
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 33 deletions.
4 changes: 2 additions & 2 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ struct _Get_rebind_alias<_Ty, _Other, void_t<typename _Ty::template rebind<_Othe

#if _HAS_CXX20
_EXPORT_STD template <class _Ty, class... _Types>
requires requires(_Ty* _Location, _Types&&... _Args) {
::new (static_cast<void*>(_Location)) _Ty(_STD forward<_Types>(_Args)...); // per LWG-3888
requires requires(void* _VoidPtr, _Types&&... _Args) {
::new (_VoidPtr) _Ty(_STD forward<_Types>(_Args)...); // per LWG-3888
}
constexpr _Ty* construct_at(_Ty* const _Location, _Types&&... _Args) noexcept(
noexcept(::new(static_cast<void*>(_Location)) _Ty(_STD forward<_Types>(_Args)...))) /* strengthened */ {
Expand Down
14 changes: 5 additions & 9 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -576,15 +576,17 @@ std/input.output/filesystems/class.path/range_concept_conformance.compile.pass.c
# This test is bogus according to the wording that was ultimately accepted for C++23.
std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp FAIL

# contiguous_iterator requires to_address() which calls operator->(), but this bogus test uses an iterator that lacks operator->().
# libc++ speculatively implements the proposed resolution for LWG-4058.
std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp FAIL

# Bogus test expects to_address() to SFINAE away for int.
std/utilities/memory/pointer.conversion/to_address_without_pointer_traits.pass.cpp FAIL

# We disagree about whether various chrono types should be optimized, and the test is clearly wrong about vector<bool>::reference.
std/utilities/format/format.formatter/format.formatter.locking/enable_nonlocking_formatter_optimization.compile.pass.cpp FAIL

# `increasing_allocator` calls `std::allocator::deallocate` with the wrong size
std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp FAIL
std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp FAIL


# *** LIKELY STL BUGS ***
# Not analyzed, likely STL bugs. Various assertions.
Expand Down Expand Up @@ -1221,12 +1223,6 @@ std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/ostream.pa
# Not analyzed. static_assert(testComplexity()) is failing.
std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_complexity.pass.cpp FAIL

# Not analyzed.
# MSVC constexpr error: failure was caused by unexpected deallocation count
# Clang assertion: _CrtIsValidHeapPointer(block)
std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp FAIL
std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp FAIL

# Not analyzed.
# MSVC truncation warnings.
# Clang assertion: std::hermite(n, +inf) == inf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ class ContiguousIterator {
public:
using value_type = int;
using difference_type = int;
using element_type = int;
using iterator_category = std::contiguous_iterator_tag;
int* operator->() const;
int& operator*() const;
int& operator[](int) const;

value_type* operator->() const;
value_type& operator*() const;
value_type& operator[](difference_type) const;
ContiguousIterator& operator++();
ContiguousIterator operator++(int);
ContiguousIterator& operator--();
ContiguousIterator operator--(int);
ContiguousIterator& operator+=(int);
ContiguousIterator& operator-=(int);
ContiguousIterator& operator+=(difference_type);
ContiguousIterator& operator-=(difference_type);
friend auto operator<=>(ContiguousIterator, ContiguousIterator) = default;
friend int operator-(ContiguousIterator, ContiguousIterator);
friend ContiguousIterator operator+(ContiguousIterator, int);
friend ContiguousIterator operator-(ContiguousIterator, int);
friend ContiguousIterator operator+(int, ContiguousIterator);
friend difference_type operator-(ContiguousIterator, ContiguousIterator);
friend ContiguousIterator operator+(ContiguousIterator, difference_type);
friend ContiguousIterator operator-(ContiguousIterator, difference_type);
friend ContiguousIterator operator+(difference_type, ContiguousIterator);
};

static_assert(std::contiguous_iterator<ContiguousIterator>);
Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/P1206R7_ranges_to_mappish/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct mappish_instantiator {
assert(c6.get_allocator().state == 13);
assert(ranges::is_permutation(c6, expected, any_pair_eq));
}
#endif
#endif // ^^^ no workaround ^^^
{
std::same_as<T> auto c7 = R{some_pairs} | ranges::to<C>(Alloc{13});
assert(c7.get_allocator().state == 13);
Expand Down
8 changes: 4 additions & 4 deletions tests/std/tests/P1206R7_ranges_to_misc/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ constexpr bool test_reservable() {
assert(r.cap_ == ranges::size(some_ints));
assert(r.reserved_ == ranges::size(some_ints));
}
#endif
#endif // ^^^ no workaround ^^^

return true;
}
Expand Down Expand Up @@ -100,7 +100,7 @@ constexpr bool test_common_constructible() {
assert(c1.last_ == ranges::end(some_ints));
assert(c1.args_ == 3);
}
#endif
#endif // ^^^ no workaround ^^^

// Verify that more than one argument can be passed after the range:
{
Expand All @@ -116,7 +116,7 @@ constexpr bool test_common_constructible() {
assert(c3.last_ == ranges::end(some_ints));
assert(c3.args_ == 4);
}
#endif
#endif // ^^^ no workaround ^^^

return true;
}
Expand Down Expand Up @@ -315,7 +315,7 @@ constexpr void test_lwg4016_per_kind() {
std::same_as<V> auto vec = std::views::empty<int> | ranges::to<V>(std::size_t{42}, std::allocator<int>{});
assert(ranges::equal(vec, std::views::repeat(0, 42)));
}
#endif
#endif // ^^^ no workaround ^^^
{
std::same_as<V> auto vec = ranges::to<V>(std::views::iota(0, 42), std::initializer_list<int>{-3, -2, -1});
assert(ranges::equal(vec, std::views::iota(-3, 42)));
Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/P1206R7_ranges_to_sequence/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ struct sequence_instantiator {
assert(c6.get_allocator().state == 13);
assert(ranges::equal(c6, meow));
}
#endif
#endif // ^^^ no workaround ^^^
{
std::same_as<T> auto c7 = R{meow} | ranges::to<C>(Alloc{13});
assert(c7.get_allocator().state == 13);
Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/P1206R7_ranges_to_settish/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct settish_instantiator {
assert(c6.get_allocator().state == 13);
assert(ranges::is_permutation(c6, expected));
}
#endif
#endif // ^^^ no workaround ^^^
{
std::same_as<T> auto c7 = R{some_ints} | ranges::to<C>(Alloc{13});
assert(c7.get_allocator().state == 13);
Expand Down
2 changes: 0 additions & 2 deletions tests/std/tests/P2136R3_invoke_r/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <string>
#include <type_traits>

#include <is_permissive.hpp>

using namespace std;

constexpr int square(int n) {
Expand Down
6 changes: 3 additions & 3 deletions tools/format/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ execute_process(
if(clang_format_version MATCHES "clang-format version ([0-9]+\.[0-9]+\.[0-9]+)")
set(expected_version "17.0.3")
if(CMAKE_MATCH_1 VERSION_LESS expected_version)
message(FATAL_ERROR "Found clang-format ${CMAKE_MATCH_1}, older than expected ${expected_version}.")
message(FATAL_ERROR "Found clang-format: ${CLANG_FORMAT} (\"${CMAKE_MATCH_1}\", older than expected version \"${expected_version}\")")
elseif(CMAKE_MATCH_1 VERSION_EQUAL expected_version)
message(STATUS "Found clang-format ${CMAKE_MATCH_1}.")
message(STATUS "Found clang-format: ${CLANG_FORMAT} (found expected version \"${CMAKE_MATCH_1}\")")
elseif(CMAKE_MATCH_1 VERSION_GREATER expected_version)
message(WARNING "Found clang-format ${CMAKE_MATCH_1}, newer than expected ${expected_version}.")
message(WARNING "Found clang-format: ${CLANG_FORMAT} (\"${CMAKE_MATCH_1}\", newer than expected version \"${expected_version}\")")
endif()
else()
message(FATAL_ERROR "Unexpected `clang-format --version` output: '${clang_format_version}'")
Expand Down

0 comments on commit cff3446

Please sign in to comment.