Skip to content

Commit 219511a

Browse files
committed
[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.
1 parent c482fad commit 219511a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/lib/APINotes/APINotesWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ void emitVersionedInfo(
441441
std::sort(VI.begin(), VI.end(),
442442
[](const std::pair<VersionTuple, T> &LHS,
443443
const std::pair<VersionTuple, T> &RHS) -> bool {
444-
assert(LHS.first != RHS.first &&
444+
assert((&LHS == &RHS || LHS.first != RHS.first) &&
445445
"two entries for the same version");
446446
return LHS.first < RHS.first;
447447
});

0 commit comments

Comments
 (0)