[clang] af2968e - [clang] Fix invalid comparator in tablegen

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 16 15:39:06 PDT 2020


Author: Eric Fiselier
Date: 2020-04-16T18:38:32-04:00
New Revision: af2968e37f4c95846ffe287b64a4fcd72c765bee

URL: https://github.com/llvm/llvm-project/commit/af2968e37f4c95846ffe287b64a4fcd72c765bee
DIFF: https://github.com/llvm/llvm-project/commit/af2968e37f4c95846ffe287b64a4fcd72c765bee.diff

LOG: [clang] Fix invalid comparator in tablegen

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

Reviewers: fowles, bkramer, sdesmalen

Reviewed By: sdesmalen

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78323

Added: 
    

Modified: 
    clang/utils/TableGen/SveEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp
index 79258a8fbbf2..8ef65612a243 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -33,6 +33,7 @@
 #include <sstream>
 #include <set>
 #include <cctype>
+#include <tuple>
 
 using namespace llvm;
 
@@ -909,9 +910,10 @@ void SVEEmitter::createHeader(raw_ostream &OS) {
   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 = "";


        


More information about the cfe-commits mailing list