[llvm] [TableGen] Migrate Opt/OptRST Emitters to const RecordKeeper (PR #107696)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 06:24:34 PDT 2024
================
@@ -250,15 +250,15 @@ static void EmitHelpTextsForVariants(
/// OptParserEmitter - This tablegen backend takes an input .td file
/// describing a list of options and emits a data structure for parsing and
/// working with those options when given an input command line.
-static void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) {
+static void EmitOptParser(const RecordKeeper &Records, raw_ostream &OS) {
// Get the option groups and options.
- const std::vector<Record *> &Groups =
+ ArrayRef<const Record *> Groups =
Records.getAllDerivedDefinitions("OptionGroup");
- std::vector<Record *> Opts = Records.getAllDerivedDefinitions("Option");
+ std::vector<const Record *> Opts = Records.getAllDerivedDefinitions("Option");
emitSourceFileHeader("Option Parsing Definitions", OS);
- array_pod_sort(Opts.begin(), Opts.end(), CompareOptionRecords);
----------------
jurahul wrote:
This was mostly straightforward modulo this part, where changing from array_pod_sort to llvm::sort() caused problems since `CompareOptionRecords` now needs to return bool, but compilation succeeds without issues if it does not and fails with strange errors at runtime
https://stackoverflow.com/questions/44278059/c-invalid-comparator
https://github.com/llvm/llvm-project/pull/107696
More information about the llvm-commits
mailing list