[llvm-branch-commits] [llvm] a396e2e - [utils] Use llvm::sort (NFC)

Kazu Hirata via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jan 15 21:06:12 PST 2021


Author: Kazu Hirata
Date: 2021-01-15T21:00:52-08:00
New Revision: a396e2e088eeab974a5d386df9466757a4bdced0

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

LOG: [utils] Use llvm::sort (NFC)

Added: 
    

Modified: 
    llvm/utils/FileCheck/FileCheck.cpp
    llvm/utils/TableGen/GlobalISel/GIMatchDag.cpp
    llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index 1721b23ad7b5..be277566620e 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -519,54 +519,54 @@ static void DumpAnnotatedInput(raw_ostream &OS, const FileCheckRequest &Req,
   OS << "Input was:\n<<<<<<\n";
 
   // Sort annotations.
-  std::sort(Annotations.begin(), Annotations.end(),
-            [](const InputAnnotation &A, const InputAnnotation &B) {
-              // 1. Sort annotations in the order of the input lines.
-              //
-              // This makes it easier to find relevant annotations while
-              // iterating input lines in the implementation below.  FileCheck
-              // does not always produce diagnostics in the order of input
-              // lines due to, for example, CHECK-DAG and CHECK-NOT.
-              if (A.InputLine != B.InputLine)
-                return A.InputLine < B.InputLine;
-              // 2. Sort annotations in the temporal order FileCheck produced
-              // their associated diagnostics.
-              //
-              // This sort offers several benefits:
-              //
-              // A. On a single input line, the order of annotations reflects
-              //    the FileCheck logic for processing directives/patterns.
-              //    This can be helpful in understanding cases in which the
-              //    order of the associated directives/patterns in the check
-              //    file or on the command line either (i) does not match the
-              //    temporal order in which FileCheck looks for matches for the
-              //    directives/patterns (due to, for example, CHECK-LABEL,
-              //    CHECK-NOT, or `--implicit-check-not`) or (ii) does match
-              //    that order but does not match the order of those
-              //    diagnostics along an input line (due to, for example,
-              //    CHECK-DAG).
-              //
-              //    On the other hand, because our presentation format presents
-              //    input lines in order, there's no clear way to offer the
-              //    same benefit across input lines.  For consistency, it might
-              //    then seem worthwhile to have annotations on a single line
-              //    also sorted in input order (that is, by input column).
-              //    However, in practice, this appears to be more confusing
-              //    than helpful.  Perhaps it's intuitive to expect annotations
-              //    to be listed in the temporal order in which they were
-              //    produced except in cases the presentation format obviously
-              //    and inherently cannot support it (that is, across input
-              //    lines).
-              //
-              // B. When diagnostics' annotations are split among multiple
-              //    input lines, the user must track them from one input line
-              //    to the next.  One property of the sort chosen here is that
-              //    it facilitates the user in this regard by ensuring the
-              //    following: when comparing any two input lines, a
-              //    diagnostic's annotations are sorted in the same position
-              //    relative to all other diagnostics' annotations.
-              return A.DiagIndex < B.DiagIndex;
-            });
+  llvm::sort(Annotations,
+             [](const InputAnnotation &A, const InputAnnotation &B) {
+               // 1. Sort annotations in the order of the input lines.
+               //
+               // This makes it easier to find relevant annotations while
+               // iterating input lines in the implementation below.  FileCheck
+               // does not always produce diagnostics in the order of input
+               // lines due to, for example, CHECK-DAG and CHECK-NOT.
+               if (A.InputLine != B.InputLine)
+                 return A.InputLine < B.InputLine;
+               // 2. Sort annotations in the temporal order FileCheck produced
+               // their associated diagnostics.
+               //
+               // This sort offers several benefits:
+               //
+               // A. On a single input line, the order of annotations reflects
+               //    the FileCheck logic for processing directives/patterns.
+               //    This can be helpful in understanding cases in which the
+               //    order of the associated directives/patterns in the check
+               //    file or on the command line either (i) does not match the
+               //    temporal order in which FileCheck looks for matches for the
+               //    directives/patterns (due to, for example, CHECK-LABEL,
+               //    CHECK-NOT, or `--implicit-check-not`) or (ii) does match
+               //    that order but does not match the order of those
+               //    diagnostics along an input line (due to, for example,
+               //    CHECK-DAG).
+               //
+               //    On the other hand, because our presentation format presents
+               //    input lines in order, there's no clear way to offer the
+               //    same benefit across input lines.  For consistency, it might
+               //    then seem worthwhile to have annotations on a single line
+               //    also sorted in input order (that is, by input column).
+               //    However, in practice, this appears to be more confusing
+               //    than helpful.  Perhaps it's intuitive to expect annotations
+               //    to be listed in the temporal order in which they were
+               //    produced except in cases the presentation format obviously
+               //    and inherently cannot support it (that is, across input
+               //    lines).
+               //
+               // B. When diagnostics' annotations are split among multiple
+               //    input lines, the user must track them from one input line
+               //    to the next.  One property of the sort chosen here is that
+               //    it facilitates the user in this regard by ensuring the
+               //    following: when comparing any two input lines, a
+               //    diagnostic's annotations are sorted in the same position
+               //    relative to all other diagnostics' annotations.
+               return A.DiagIndex < B.DiagIndex;
+             });
 
   // Compute the width of the label column.
   const unsigned char *InputFilePtr = InputFileText.bytes_begin(),

diff  --git a/llvm/utils/TableGen/GlobalISel/GIMatchDag.cpp b/llvm/utils/TableGen/GlobalISel/GIMatchDag.cpp
index a3a9b7d8b037..7e037dd03b60 100644
--- a/llvm/utils/TableGen/GlobalISel/GIMatchDag.cpp
+++ b/llvm/utils/TableGen/GlobalISel/GIMatchDag.cpp
@@ -41,7 +41,7 @@ void GIMatchDag::writeDOTGraph(raw_ostream &OS, StringRef ID) const {
     SmallVector<std::pair<unsigned, StringRef>, 8> ToPrint;
     for (const auto &Assignment : N->user_assigned_operand_names())
       ToPrint.emplace_back(Assignment.first, Assignment.second);
-    llvm::sort(ToPrint.begin(), ToPrint.end());
+    llvm::sort(ToPrint);
     StringRef Separator = "";
     for (const auto &Assignment : ToPrint) {
       OS << Separator << "$" << Assignment.second << "=getOperand("

diff  --git a/llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.cpp b/llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.cpp
index 218b741be20c..ad9fbea8f881 100644
--- a/llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.cpp
+++ b/llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.cpp
@@ -27,7 +27,7 @@ void GIMatchDagInstr::print(raw_ostream &OS) const {
     SmallVector<std::pair<unsigned, StringRef>, 8> ToPrint;
     for (const auto &Assignment : UserAssignedNamesForOperands)
       ToPrint.emplace_back(Assignment.first, Assignment.second);
-    llvm::sort(ToPrint.begin(), ToPrint.end());
+    llvm::sort(ToPrint);
     StringRef Separator = "";
     for (const auto &Assignment : ToPrint) {
       OS << Separator << "$" << Assignment.second << "=getOperand("


        


More information about the llvm-branch-commits mailing list