[llvm] [utils][TableGen] Handle versions on clause/directive spellings (PR #143021)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 04:41:36 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) {
----------------
jurahul wrote:
nit: use real type `RecordWithSpelling`
https://github.com/llvm/llvm-project/pull/143021
More information about the llvm-commits
mailing list