Skip to content

Conversation

@mgorny
Copy link
Member

@mgorny mgorny commented Dec 20, 2025

Reverts #172536. This is causing weird assertion failures in clang, per #172536 (comment). It might be a bug in GCC, but still makes sense to revert it in the interest of bootstrapping.

@llvmbot
Copy link
Member

llvmbot commented Dec 20, 2025

@llvm/pr-subscribers-llvm-adt

Author: Michał Górny (mgorny)

Changes

Reverts llvm/llvm-project#172536. This is causing weird assertion failures in clang, per #172536 (comment). It might be a bug in GCC, but still makes sense to revert it in the interest of bootstrapping.


Full diff: https://github.com/llvm/llvm-project/pull/173163.diff

2 Files Affected:

  • (modified) llvm/include/llvm/ADT/STLExtras.h (+8-17)
  • (modified) llvm/unittests/ADT/STLExtrasTest.cpp (-19)
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index d4632ab72e563..409cd7b60fa00 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -638,10 +638,10 @@ make_early_inc_range(RangeT &&Range) {
 
 // Forward declarations required by zip_shortest/zip_equal/zip_first/zip_longest
 template <typename R, typename UnaryPredicate>
-constexpr bool all_of(R &&range, UnaryPredicate P);
+bool all_of(R &&range, UnaryPredicate P);
 
 template <typename R, typename UnaryPredicate>
-constexpr bool any_of(R &&range, UnaryPredicate P);
+bool any_of(R &&range, UnaryPredicate P);
 
 template <typename T> bool all_equal(std::initializer_list<T> Values);
 
@@ -1734,31 +1734,22 @@ UnaryFunction for_each(R &&Range, UnaryFunction F) {
 /// Provide wrappers to std::all_of which take ranges instead of having to pass
 /// begin/end explicitly.
 template <typename R, typename UnaryPredicate>
-constexpr bool all_of(R &&Range, UnaryPredicate P) {
-  // TODO: switch back to std::all_of() after it becomes constexpr in c++20.
-  for (auto I = adl_begin(Range), E = adl_end(Range); I != E; ++I)
-    if (!P(*I))
-      return false;
-  return true;
+bool all_of(R &&Range, UnaryPredicate P) {
+  return std::all_of(adl_begin(Range), adl_end(Range), P);
 }
 
 /// Provide wrappers to std::any_of which take ranges instead of having to pass
 /// begin/end explicitly.
 template <typename R, typename UnaryPredicate>
-constexpr bool any_of(R &&Range, UnaryPredicate P) {
-  // TODO: switch back to std::any_of() after it becomes constexpr in c++20.
-  for (auto I = adl_begin(Range), E = adl_end(Range); I != E; ++I)
-    if (P(*I))
-      return true;
-  return false;
+bool any_of(R &&Range, UnaryPredicate P) {
+  return std::any_of(adl_begin(Range), adl_end(Range), P);
 }
 
 /// Provide wrappers to std::none_of which take ranges instead of having to pass
 /// begin/end explicitly.
 template <typename R, typename UnaryPredicate>
-constexpr bool none_of(R &&Range, UnaryPredicate P) {
-  // TODO: switch back to std::none_of() after it becomes constexpr in c++20.
-  return !any_of(Range, P);
+bool none_of(R &&Range, UnaryPredicate P) {
+  return std::none_of(adl_begin(Range), adl_end(Range), P);
 }
 
 /// Provide wrappers to std::fill which take ranges instead of having to pass
diff --git a/llvm/unittests/ADT/STLExtrasTest.cpp b/llvm/unittests/ADT/STLExtrasTest.cpp
index da84345eecda8..dbf439b8d63a0 100644
--- a/llvm/unittests/ADT/STLExtrasTest.cpp
+++ b/llvm/unittests/ADT/STLExtrasTest.cpp
@@ -1260,25 +1260,6 @@ TEST(STLExtras, MoveRange) {
   EXPECT_TRUE(llvm::all_of(V4, HasVal));
 }
 
-TEST(STLExtrasTest, AllOfAnyOfNoneOfConstexpr) {
-  // Verify constexpr evaluation works. Functional correctness is tested in
-  // runtime tests (e.g., MoveRange).
-  constexpr std::array<int, 3> Arr = {1, 2, 3};
-  static_assert(all_of(Arr, [](int X) { return X > 0; }));
-  static_assert(any_of(Arr, [](int X) { return X == 2; }));
-  static_assert(none_of(Arr, [](int X) { return X < 0; }));
-
-  // Verify constexpr works with C-style arrays.
-  constexpr int CArr[] = {1, 2};
-  static_assert(all_of(CArr, [](int X) { return X > 0; }));
-
-  // Verify empty range edge case.
-  constexpr std::array<int, 0> Empty = {};
-  static_assert(all_of(Empty, [](int) { return false; }));
-  static_assert(!any_of(Empty, [](int) { return true; }));
-  static_assert(none_of(Empty, [](int) { return true; }));
-}
-
 TEST(STLExtras, Unique) {
   std::vector<int> V = {1, 5, 5, 4, 3, 3, 3};
 

@github-actions
Copy link

github-actions bot commented Dec 20, 2025

🪟 Windows x64 Test Results

  • 128833 tests passed
  • 2837 tests skipped

✅ The build succeeded and all tests passed.

@github-actions
Copy link

github-actions bot commented Dec 20, 2025

🐧 Linux x64 Test Results

  • 187685 tests passed
  • 4984 tests skipped

✅ The build succeeded and all tests passed.

@github-actions
Copy link

github-actions bot commented Dec 20, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
@mgorny mgorny merged commit 7d0773b into main Dec 21, 2025
7 of 10 checks passed
@mgorny mgorny deleted the revert-172536-jiachen/all_any_none_of branch December 21, 2025 02:47
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 21, 2025

LLVM Buildbot has detected a new failure on builder clang-m68k-linux-cross running on suse-gary-m68k-cross while building llvm at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/20615

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants