Skip to content

[STLExtras] Add a template for detecting whether a type has an equality comparison operator#176429

Merged
jmorse merged 3 commits into
llvm:mainfrom
BStott6:stlextras-equality-comparison-detection
Jan 19, 2026
Merged

[STLExtras] Add a template for detecting whether a type has an equality comparison operator#176429
jmorse merged 3 commits into
llvm:mainfrom
BStott6:stlextras-equality-comparison-detection

Conversation

@BStott6
Copy link
Copy Markdown
Contributor

@BStott6 BStott6 commented Jan 16, 2026

This is needed for #173026.

@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Jan 16, 2026

@llvm/pr-subscribers-llvm-adt

Author: Benjamin Stott (BStott6)

Changes

This is needed for #173026.


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

2 Files Affected:

  • (modified) llvm/include/llvm/ADT/STLExtras.h (+11)
  • (modified) llvm/unittests/ADT/STLExtrasTest.cpp (+22)
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 23da931a63de1..fd31430ede911 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -2682,6 +2682,17 @@ template <typename T> using has_sizeof = decltype(sizeof(T));
 template <typename T>
 constexpr bool is_incomplete_v = !is_detected<detail::has_sizeof, T>::value;
 
+// Detect types with equality comparison operators.
+namespace detail {
+template <typename T>
+using has_equality_comparison =
+    decltype(std::declval<const T &>() == std::declval<const T &>());
+} // namespace detail
+
+/// Detects when type `const T` can be compared for equality with itself.
+template <typename T>
+constexpr bool has_equality_comparison_v =
+    is_detected<detail::has_equality_comparison, T>::value;
 } // end namespace llvm
 
 namespace std {
diff --git a/llvm/unittests/ADT/STLExtrasTest.cpp b/llvm/unittests/ADT/STLExtrasTest.cpp
index fe71945e4a794..02b4eee04d005 100644
--- a/llvm/unittests/ADT/STLExtrasTest.cpp
+++ b/llvm/unittests/ADT/STLExtrasTest.cpp
@@ -1780,6 +1780,28 @@ struct Bar {};
 static_assert(is_incomplete_v<Foo>, "Foo is incomplete");
 static_assert(!is_incomplete_v<Bar>, "Bar is defined");
 
+struct NoEqualityComparison {};
+static_assert(!has_equality_comparison_v<NoEqualityComparison>);
+
+// Mutating equality comparison doesn't count.
+struct MutatingEqualityComparison {
+  bool operator==(MutatingEqualityComparison &Other) { return false; }
+};
+static_assert(!has_equality_comparison_v<MutatingEqualityComparison>);
+
+struct PrivateEqualityComparison {
+private:
+  bool operator==(const PrivateEqualityComparison &Other) const {
+    return false;
+  }
+};
+static_assert(!has_equality_comparison_v<PrivateEqualityComparison>);
+
+struct PublicEqualityComparison {
+  bool operator==(const PublicEqualityComparison &Other) const { return false; }
+};
+static_assert(has_equality_comparison_v<PublicEqualityComparison>);
+
 TEST(STLExtrasTest, Search) {
   // Test finding a subsequence in the middle.
   std::vector<int> Haystack = {1, 2, 3, 4, 5, 6, 7, 8};

Comment thread llvm/include/llvm/ADT/STLExtras.h Outdated
Comment thread llvm/unittests/ADT/STLExtrasTest.cpp Outdated
Copy link
Copy Markdown
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % test structure

@jmorse jmorse merged commit a66b8b7 into llvm:main Jan 19, 2026
11 checks passed
@BStott6
Copy link
Copy Markdown
Contributor Author

BStott6 commented Jan 19, 2026

Thanks! And thank you kuhar for the tips

@llvm-ci
Copy link
Copy Markdown

llvm-ci commented Jan 19, 2026

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-win-fast running on as-builder-3 while building llvm at step 7 "test-build-unified-tree-check-llvm-unit".

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

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-llvm-unit) failure: test (failure)
...
[84/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\RangeAdapterTest.cpp.obj
[85/799] Linking CXX executable unittests\Demangle\DemangleTests.exe
[86/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SetOperationsTest.cpp.obj
[87/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PackedVectorTest.cpp.obj
[88/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PagedVectorTest.cpp.obj
[89/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PostOrderIteratorTest.cpp.obj
[90/799] Building CXX object unittests\Analysis\CMakeFiles\AnalysisTests.dir\CGSCCPassManagerTest.cpp.obj
[91/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SimpleIListTest.cpp.obj
[92/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PointerUnionTest.cpp.obj
[93/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\STLExtrasTest.cpp.obj
FAILED: unittests/ADT/CMakeFiles/ADTTests.dir/STLExtrasTest.cpp.obj 
C:\ninja\ccache.exe C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe  /nologo /TP -DLLVM_BUILD_STATIC -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\unittests\ADT -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\unittests\ADT -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\include -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\include -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\third-party\unittest\googletest\include -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\third-party\unittest\googlemock\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -MD /EHs-c- /GR- -std:c++17 /showIncludes /Founittests\ADT\CMakeFiles\ADTTests.dir\STLExtrasTest.cpp.obj /Fdunittests\ADT\CMakeFiles\ADTTests.dir\ /FS -c C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\unittests\ADT\STLExtrasTest.cpp
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\unittests\ADT\STLExtrasTest.cpp(1799): error C2607: static assertion failed
[94/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\StringSetTest.cpp.obj
[95/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PriorityWorklistTest.cpp.obj
[96/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SparseMultiSetTest.cpp.obj
[97/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\TypeTraitsTest.cpp.obj
[98/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SetVectorTest.cpp.obj
[99/799] Building CXX object unittests\ExecutionEngine\JITLink\CMakeFiles\JITLinkTests.dir\LinkGraphTests.cpp.obj
[100/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\TypeSwitchTest.cpp.obj
[101/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SparseBitVectorTest.cpp.obj
[102/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SmallVectorExtrasTest.cpp.obj
[103/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SequenceTest.cpp.obj
[104/799] Building CXX object unittests\Analysis\CMakeFiles\AnalysisTests.dir\ConstraintSystemTest.cpp.obj
[105/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\TwineTest.cpp.obj
[106/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\MapVectorTest.cpp.obj
[107/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\IteratorTest.cpp.obj
[108/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\BitVectorTest.cpp.obj
[109/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SparseSetTest.cpp.obj
[110/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\StringSwitchTest.cpp.obj
[111/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\STLForwardCompatTest.cpp.obj
[112/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\TrieRawHashMapTest.cpp.obj
[113/799] Building CXX object unittests\Analysis\CMakeFiles\AnalysisTests.dir\CFGTest.cpp.obj
[114/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\StringRefTest.cpp.obj
[115/799] Building CXX object unittests\Analysis\CMakeFiles\AnalysisTests.dir\CallGraphTest.cpp.obj
[116/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SmallStringTest.cpp.obj
[117/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SmallPtrSetTest.cpp.obj
[118/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SmallSetTest.cpp.obj
[119/799] Building CXX object unittests\Analysis\CMakeFiles\AnalysisTests.dir\CaptureTrackingTest.cpp.obj
[120/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\StringTableTest.cpp.obj
[121/799] Building CXX object unittests\Analysis\CMakeFiles\AnalysisTests.dir\AliasAnalysisTest.cpp.obj
[122/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\IntervalTreeTest.cpp.obj
[123/799] Building CXX object unittests\Analysis\CMakeFiles\AnalysisTests.dir\AliasSetTrackerTest.cpp.obj
[124/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\TinyPtrVectorTest.cpp.obj
[125/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\IntervalMapTest.cpp.obj
[126/799] Building CXX object unittests\Analysis\CMakeFiles\AnalysisTests.dir\GlobalsModRefTest.cpp.obj
[127/799] Building CXX object unittests\Analysis\CMakeFiles\AnalysisTests.dir\DDGTest.cpp.obj
[128/799] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\StringMapTest.cpp.obj
[129/799] Building CXX object unittests\Analysis\CMakeFiles\AnalysisTests.dir\DomTreeUpdaterTest.cpp.obj

@llvm-ci
Copy link
Copy Markdown

llvm-ci commented Jan 19, 2026

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-win running on sie-win-worker while building llvm at step 7 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
[414/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\ImmutableListTest.cpp.obj
[415/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\ImmutableMapTest.cpp.obj
[416/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\IntrusiveRefCntPtrTest.cpp.obj
[417/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PriorityWorklistTest.cpp.obj
[418/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PointerEmbeddedIntTest.cpp.obj
[419/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\IntervalMapTest.cpp.obj
[420/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\MappedIteratorTest.cpp.obj
[421/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PagedVectorTest.cpp.obj
[422/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\ScopedHashTableTest.cpp.obj
[423/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\STLExtrasTest.cpp.obj
FAILED: unittests/ADT/CMakeFiles/ADTTests.dir/STLExtrasTest.cpp.obj 
C:\bin\ccache.exe C:\PROGRA~2\MICROS~1\2019\BUILDT~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\cl.exe  /nologo /TP -DLLVM_BUILD_STATIC -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iunittests\ADT -IZ:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\unittests\ADT -Iinclude -IZ:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\include -IZ:\b\llvm-clang-x86_64-sie-win\llvm-project\third-party\unittest\googletest\include -IZ:\b\llvm-clang-x86_64-sie-win\llvm-project\third-party\unittest\googlemock\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD -UNDEBUG /EHs-c- /GR- -std:c++17 /showIncludes /Founittests\ADT\CMakeFiles\ADTTests.dir\STLExtrasTest.cpp.obj /Fdunittests\ADT\CMakeFiles\ADTTests.dir\ /FS -c Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\unittests\ADT\STLExtrasTest.cpp
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\include\llvm/ADT/STLExtras.h(167): warning C4308: negative integral constant converted to unsigned type
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\unittests\ADT\STLExtrasTest.cpp(1596): note: while evaluating constexpr function 'llvm::addEnumValues'
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\unittests\ADT\STLExtrasTest.cpp(1799): error C2607: static assertion failed
[424/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\LazyAtomicPointerTest.cpp.obj
[425/1200] Building CXX object tools\clang\unittests\Interpreter\CMakeFiles\ClangReplInterpreterTests.dir\InterpreterExtensionsTest.cpp.obj
[426/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\IntervalTreeTest.cpp.obj
[427/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\DynamicAPIntTest.cpp.obj
[428/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PointerIntPairTest.cpp.obj
[429/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PackedVectorTest.cpp.obj
[430/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\MapVectorTest.cpp.obj
[431/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PointerSumTypeTest.cpp.obj
[432/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\IteratorTest.cpp.obj
[433/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SCCIteratorTest.cpp.obj
[434/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\RewriteBufferTest.cpp.obj
[435/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\DenseMapTest.cpp.obj
[436/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PostOrderIteratorTest.cpp.obj
[437/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\RangeAdapterTest.cpp.obj
[438/1200] Building CXX object tools\clang\unittests\Sema\CMakeFiles\SemaTests.dir\SemaNoloadLookupTest.cpp.obj
[439/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\ScopeExitTest.cpp.obj
[440/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\PointerUnionTest.cpp.obj
[441/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\STLForwardCompatTest.cpp.obj
[442/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SimpleIListTest.cpp.obj
[443/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SmallVectorExtrasTest.cpp.obj
[444/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SetVectorTest.cpp.obj
[445/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SmallStringTest.cpp.obj
[446/1200] Building CXX object tools\clang\unittests\Sema\CMakeFiles\SemaTests.dir\CodeCompleteTest.cpp.obj
[447/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SetOperationsTest.cpp.obj
[448/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SmallSetTest.cpp.obj
[449/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SmallPtrSetTest.cpp.obj
[450/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\SequenceTest.cpp.obj
[451/1200] Building CXX object tools\clang\unittests\Format\CMakeFiles\FormatTests.dir\TokenAnnotatorTest.cpp.obj
[452/1200] Building CXX object tools\clang\unittests\Sema\CMakeFiles\SemaTests.dir\HeuristicResolverTest.cpp.obj
[453/1200] Building CXX object unittests\ADT\CMakeFiles\ADTTests.dir\RadixTreeTest.cpp.obj
[454/1200] Building CXX object tools\clang\unittests\Interpreter\CMakeFiles\ClangReplInterpreterTests.dir\InterpreterTest.cpp.obj
[455/1200] Building CXX object tools\clang\unittests\Interpreter\CMakeFiles\ClangReplInterpreterTests.dir\IncrementalProcessingTest.cpp.obj
[456/1200] Building CXX object tools\clang\unittests\Interpreter\CMakeFiles\ClangReplInterpreterTests.dir\CodeCompletionTest.cpp.obj
ninja: build stopped: subcommand failed.

jmorse added a commit that referenced this pull request Jan 19, 2026
…n be compared for equality (#176429)"

This reverts commit a66b8b7.

MSVC doesn't like it: https://lab.llvm.org/buildbot/#/builders/2/builds/42388/steps/7/logs/stdio
Thus we'll revert and examine that.
@kuhar
Copy link
Copy Markdown
Member

kuhar commented Jan 19, 2026

Apparently MSVC doesn't like this assertion:

static_assert(!has_equality_comparison_v<PrivateEqualityComparison>);

(https://lab.llvm.org/buildbot/#/builders/2/builds/42388/steps/7/logs/stdio)

I think we should drop it and re-land.

@llvm-ci
Copy link
Copy Markdown

llvm-ci commented Jan 19, 2026

LLVM Buildbot has detected a new failure on builder clang-debian-cpp20 running on clang-debian-cpp20 while building llvm at step 6 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
...
738.224 [726/18/569] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/ScopedHashTableTest.cpp.o
740.047 [725/18/570] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/IteratorTest.cpp.o
740.920 [724/18/571] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/MapVectorTest.cpp.o
741.762 [723/18/572] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/STLForwardCompatTest.cpp.o
741.934 [722/18/573] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SmallStringTest.cpp.o
742.040 [721/18/574] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SetVectorTest.cpp.o
742.148 [720/18/575] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SimpleIListTest.cpp.o
742.925 [719/18/576] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SetOperationsTest.cpp.o
743.011 [718/18/577] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SparseBitVectorTest.cpp.o
743.138 [717/18/578] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/STLExtrasTest.cpp.o
FAILED: unittests/ADT/CMakeFiles/ADTTests.dir/STLExtrasTest.cpp.o 
ccache /usr/bin/clang++-17 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/unittests/ADT -I/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/unittests/ADT -I/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/include -I/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/include -I/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/third-party/unittest/googletest/include -I/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/third-party/unittest/googlemock/include -Wno-deprecated-enum-enum-conversion -Wno-deprecated-declarations -Wno-deprecated-anon-enum-enum-conversion -Wno-ambiguous-reversed-operator -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++20 -UNDEBUG -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -funwind-tables -fno-rtti -Wno-suggest-override -MD -MT unittests/ADT/CMakeFiles/ADTTests.dir/STLExtrasTest.cpp.o -MF unittests/ADT/CMakeFiles/ADTTests.dir/STLExtrasTest.cpp.o.d -o unittests/ADT/CMakeFiles/ADTTests.dir/STLExtrasTest.cpp.o -c /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/unittests/ADT/STLExtrasTest.cpp
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/unittests/ADT/STLExtrasTest.cpp:1812:17: error: static assertion failed due to requirement '!has_equality_comparison_v<StructA, StructB>'
 1812 |   static_assert(!has_equality_comparison_v<StructA, StructB>);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
743.267 [717/17/579] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SparseMultiSetTest.cpp.o
743.586 [717/16/580] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SparseSetTest.cpp.o
744.093 [717/15/581] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SmallVectorExtrasTest.cpp.o
744.941 [717/14/582] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SmallSetTest.cpp.o
745.000 [717/13/583] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/StatisticTest.cpp.o
745.351 [717/12/584] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SmallPtrSetTest.cpp.o
745.947 [717/11/585] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/StringTableTest.cpp.o
746.348 [717/10/586] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/StringSetTest.cpp.o
746.406 [717/9/587] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/StringSwitchTest.cpp.o
746.566 [717/8/588] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SequenceTest.cpp.o
747.769 [717/7/589] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/StringExtrasTest.cpp.o
747.797 [717/6/590] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/StringMapTest.cpp.o
748.182 [717/5/591] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/StringRefTest.cpp.o
750.455 [717/4/592] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/TinyPtrVectorTest.cpp.o
755.878 [717/3/593] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/DenseMapTest.cpp.o
758.847 [717/2/594] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/RadixTreeTest.cpp.o
765.521 [717/1/595] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SmallVectorTest.cpp.o
ninja: build stopped: subcommand failed.

jmorse pushed a commit that referenced this pull request Jan 20, 2026
…n equality comparison operator" (#176893)

This PR is an attempt to reland
#176429.

It seems there's a difference between Clang and MSVC's template
handling, resulting in a difference in the behaviour of is_detected with
private class members. [This](https://godbolt.org/z/x61YdEz44) Godbolt
link demonstrates the difference. This was causing one of the test cases
I made, which was checking that it didn't pick up a private equality
comparison operator, to fail when compiled using MSVC.

In this PR I have just removed that test case.
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 20, 2026
… type has an equality comparison operator" (#176893)

This PR is an attempt to reland
llvm/llvm-project#176429.

It seems there's a difference between Clang and MSVC's template
handling, resulting in a difference in the behaviour of is_detected with
private class members. [This](https://godbolt.org/z/x61YdEz44) Godbolt
link demonstrates the difference. This was causing one of the test cases
I made, which was checking that it didn't pick up a private equality
comparison operator, to fail when compiled using MSVC.

In this PR I have just removed that test case.
OCHyams pushed a commit that referenced this pull request Apr 23, 2026
…s an equality comparison operator" (#177415)

Reland PR #176893 which was an attempt to reland PR #176429.

Fix:

There was a test case asserting that for types `StructA` `StructB` where
`operator==(const StructB &, const StructA &)` is defined,
`has_equality_comparison_v<StructA, StructB>` is false because the
arguments are the wrong way around. However, in C++20, operator overload
resolution was changed so that for reflexive comparison operators `==`
and `!=` if a candidate exists with the arguments swapped then this will
be used. This means the test case failed when compiled with C++20. That
check was simply removed in this version.
yingopq pushed a commit to yingopq/llvm-project that referenced this pull request Apr 29, 2026
…e has an equality comparison operator" (llvm#177415)

Reland PR llvm#176893 which was an attempt to reland PR llvm#176429.

Fix:

There was a test case asserting that for types `StructA` `StructB` where
`operator==(const StructB &, const StructA &)` is defined,
`has_equality_comparison_v<StructA, StructB>` is false because the
arguments are the wrong way around. However, in C++20, operator overload
resolution was changed so that for reflexive comparison operators `==`
and `!=` if a candidate exists with the arguments swapped then this will
be used. This means the test case failed when compiled with C++20. That
check was simply removed in this version.
KHicketts pushed a commit to KHicketts/llvm-project that referenced this pull request Apr 30, 2026
…e has an equality comparison operator" (llvm#177415)

Reland PR llvm#176893 which was an attempt to reland PR llvm#176429.

Fix:

There was a test case asserting that for types `StructA` `StructB` where
`operator==(const StructB &, const StructA &)` is defined,
`has_equality_comparison_v<StructA, StructB>` is false because the
arguments are the wrong way around. However, in C++20, operator overload
resolution was changed so that for reflexive comparison operators `==`
and `!=` if a candidate exists with the arguments swapped then this will
be used. This means the test case failed when compiled with C++20. That
check was simply removed in this version.
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