Skip to content

Commit 1094e2e

Browse files
Danila Kutenincyndyishida
authored andcommitted
[TextAPI] Make sortTargetValues strict weak ordering compliant
Second sorting was not following strict weak ordering as it does not follow transitivity of equivalence property. If you build llvm with libcxx at head as a standard library with -D_LIBCPP_DEBUG_STRICT_WEAK_ORDERING_CHECK and -D_LIBCPP_ENABLE_DEBUG_MODE, then tests like llvm/test/tools/llvm-readtapi/compare-right-single-inline.test.test will fail I don't have commit rights. Danila Kutenin [email protected] Reviewed By: cishida Differential Revision: https://reviews.llvm.org/D157958
1 parent 845d3b5 commit 1094e2e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/tools/llvm-readtapi/DiffEngine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,11 @@ T *castValues(const std::unique_ptr<AttributeDiff> &RawAttr) {
447447

448448
template <typename T> void sortTargetValues(std::vector<T> &TargValues) {
449449
llvm::stable_sort(TargValues, [](const auto &ValA, const auto &ValB) {
450+
if (ValA.getOrder() == ValB.getOrder()) {
451+
return ValA.getVal() < ValB.getVal();
452+
}
450453
return ValA.getOrder() < ValB.getOrder();
451454
});
452-
llvm::stable_sort(TargValues, [](const auto &ValA, const auto &ValB) {
453-
return ValA.getOrder() == ValB.getOrder() && ValA.getVal() < ValB.getVal();
454-
});
455455
}
456456

457457
template <typename T>

0 commit comments

Comments
 (0)