[llvm] 1094e2e - [TextAPI] Make sortTargetValues strict weak ordering compliant
Cyndy Ishida via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 21 08:57:24 PDT 2023
Author: Danila Kutenin
Date: 2023-08-21T08:56:39-07:00
New Revision: 1094e2ebbae6a9ba540b9fd84ea434eff8c3676f
URL: https://github.com/llvm/llvm-project/commit/1094e2ebbae6a9ba540b9fd84ea434eff8c3676f
DIFF: https://github.com/llvm/llvm-project/commit/1094e2ebbae6a9ba540b9fd84ea434eff8c3676f.diff
LOG: [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 kudanila at yandex.ru
Reviewed By: cishida
Differential Revision: https://reviews.llvm.org/D157958
Added:
Modified:
llvm/tools/llvm-readtapi/DiffEngine.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-readtapi/DiffEngine.cpp b/llvm/tools/llvm-readtapi/DiffEngine.cpp
index f149b1b97d58e5..c10e74725a92d7 100644
--- a/llvm/tools/llvm-readtapi/DiffEngine.cpp
+++ b/llvm/tools/llvm-readtapi/DiffEngine.cpp
@@ -447,11 +447,11 @@ T *castValues(const std::unique_ptr<AttributeDiff> &RawAttr) {
template <typename T> void sortTargetValues(std::vector<T> &TargValues) {
llvm::stable_sort(TargValues, [](const auto &ValA, const auto &ValB) {
+ if (ValA.getOrder() == ValB.getOrder()) {
+ return ValA.getVal() < ValB.getVal();
+ }
return ValA.getOrder() < ValB.getOrder();
});
- llvm::stable_sort(TargValues, [](const auto &ValA, const auto &ValB) {
- return ValA.getOrder() == ValB.getOrder() && ValA.getVal() < ValB.getVal();
- });
}
template <typename T>
More information about the llvm-commits
mailing list