Author: Dmitri Gribenko Date: 2024-03-28T23:11:58+01:00 New Revision: 219511aee21cc652e1ede0458de4a4a66f04c81c
URL: https://github.com/llvm/llvm-project/commit/219511aee21cc652e1ede0458de4a4a66f04c81c DIFF: https://github.com/llvm/llvm-project/commit/219511aee21cc652e1ede0458de4a4a66f04c81c.diff LOG: [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. Added: Modified: clang/lib/APINotes/APINotesWriter.cpp Removed: ################################################################################ diff --git a/clang/lib/APINotes/APINotesWriter.cpp b/clang/lib/APINotes/APINotesWriter.cpp index 76fd24ccfae984..e3f5d102fcd07f 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; }); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits