[PATCH] D78323: [clang] Fix invalid comparator in tablegen

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 16 13:23:23 PDT 2020


EricWF created this revision.
EricWF added reviewers: fowles, bkramer, sdesmalen.
Herald added a project: clang.

The current version of the comparator does not introduce a strict weak ordering.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78323

Files:
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===================================================================
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -33,6 +33,7 @@
 #include <sstream>
 #include <set>
 #include <cctype>
+#include <tuple>
 
 using namespace llvm;
 
@@ -909,9 +910,10 @@
   std::stable_sort(
       Defs.begin(), Defs.end(), [](const std::unique_ptr<Intrinsic> &A,
                                    const std::unique_ptr<Intrinsic> &B) {
-        return A->getGuard() < B->getGuard() ||
-               (unsigned)A->getClassKind() < (unsigned)B->getClassKind() ||
-               A->getName() < B->getName();
+        auto ToTuple = [](const std::unique_ptr<Intrinsic> &I) {
+          return std::make_tuple(I->getGuard(), (unsigned)I->getClassKind(), I->getName());
+        };
+        return ToTuple(A) < ToTuple(B);
       });
 
   StringRef InGuard = "";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78323.258135.patch
Type: text/x-patch
Size: 922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200416/d6c603c6/attachment-0001.bin>


More information about the cfe-commits mailing list