From a396e2e088eeab974a5d386df9466757a4bdced0 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 15 Jan 2021 21:00:52 -0800 Subject: [PATCH] [utils] Use llvm::sort (NFC) --- llvm/utils/FileCheck/FileCheck.cpp | 96 +++++++++++----------- llvm/utils/TableGen/GlobalISel/GIMatchDag.cpp | 2 +- llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.cpp | 2 +- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp index 1721b23..be27756 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 a3a9b7d..7e037dd 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, 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 218b741..ad9fbea 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, 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(" -- 2.7.4