[llvm] [utils][TableGen] Handle versions on clause/directive spellings (PR #143021)

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 06:48:10 PDT 2025


================
@@ -1144,47 +1201,29 @@ static void generateFlangClauseParserKindMap(const DirectiveLanguage &DirLang,
      << " Parser clause\");\n";
 }
 
-using RecordWithText = std::pair<const Record *, StringRef>;
-
-static bool compareRecordText(const RecordWithText &A,
-                              const RecordWithText &B) {
-  return A.second > B.second;
-}
-
-static std::vector<RecordWithText>
-getSpellingTexts(ArrayRef<const Record *> Records) {
-  std::vector<RecordWithText> List;
-  for (const Record *R : Records) {
-    Clause C(R);
-    llvm::transform(
-        C.getSpellings(), std::back_inserter(List),
-        [R](Spelling::Value V) { return std::make_pair(R, V.first); });
-  }
-  return List;
-}
-
 // Generate the parser for the clauses.
 static void generateFlangClausesParser(const DirectiveLanguage &DirLang,
                                        raw_ostream &OS) {
   std::vector<const Record *> Clauses = DirLang.getClauses();
   // Sort clauses in the reverse alphabetical order with respect to their
   // names and aliases, so that longer names are tried before shorter ones.
-  std::vector<std::pair<const Record *, StringRef>> Names =
-      getSpellingTexts(Clauses);
-  llvm::sort(Names, compareRecordText);
+  std::vector<RecordWithSpelling> Names = getSpellings(Clauses);
+  llvm::sort(Names, [](const auto &A, const auto &B) {
----------------
kparzysz wrote:

`Names` with full type is defined in the preceding line.

https://github.com/llvm/llvm-project/pull/143021


More information about the llvm-commits mailing list