aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2024-03-28 22:58:49 +0100
committerDmitri Gribenko <gribozavr@gmail.com>2024-03-28 23:11:58 +0100
commit219511aee21cc652e1ede0458de4a4a66f04c81c (patch)
treeabee6c1a28edb528a6899c6046db4d9b12be78b8
parentc482fad2c1de367f8fef2b40361dec00523707f7 (diff)
downloadllvm-219511aee21cc652e1ede0458de4a4a66f04c81c.zip
llvm-219511aee21cc652e1ede0458de4a4a66f04c81c.tar.gz
llvm-219511aee21cc652e1ede0458de4a4a66f04c81c.tar.bz2
[APINotes] Make an assert in a std::sort call tolerate self-comparisons
libc++ debug mode verifies that a comparator passed to std::sort defines a strict weak order by calling it with the same element. See also: - RFC that introduced the feature: https://discourse.llvm.org/t/rfc-strict-weak-ordering-checks-in-the-debug-libc/70217 - `strict_weak_ordering_check.h` in libc++ sources.
-rw-r--r--clang/lib/APINotes/APINotesWriter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/APINotes/APINotesWriter.cpp b/clang/lib/APINotes/APINotesWriter.cpp
index 76fd24c..e3f5d10 100644
--- a/clang/lib/APINotes/APINotesWriter.cpp
+++ b/clang/lib/APINotes/APINotesWriter.cpp
@@ -441,7 +441,7 @@ void emitVersionedInfo(
std::sort(VI.begin(), VI.end(),
[](const std::pair<VersionTuple, T> &LHS,
const std::pair<VersionTuple, T> &RHS) -> bool {
- assert(LHS.first != RHS.first &&
+ assert((&LHS == &RHS || LHS.first != RHS.first) &&
"two entries for the same version");
return LHS.first < RHS.first;
});