aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/TableGen
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2023-03-11 08:24:39 +0900
committerNAKAMURA Takumi <geek4civic@gmail.com>2023-03-31 06:00:54 +0900
commit32a5482e3c83ef7302cd9c5a1c3afb8c2c4c2d28 (patch)
treee4e62d371dec94ef59a92954dcdb950ea9f4e692 /llvm/lib/TableGen
parent7edff3c1b298f696c632625fa863acbc7d68d446 (diff)
downloadllvm-32a5482e3c83ef7302cd9c5a1c3afb8c2c4c2d28.zip
llvm-32a5482e3c83ef7302cd9c5a1c3afb8c2c4c2d28.tar.gz
llvm-32a5482e3c83ef7302cd9c5a1c3afb8c2c4c2d28.tar.bz2
TableGen: Let getAllDerivedDefinitions() numeric order.
Since `RK::Recs` is sorted by character order, anonymous defs will be enumerated like this; - anonymous_0 - anonymous_1 - anonymous_10 - anonymous_100 - anonymous_1000 - ... - anonymous_99 - anonymous_990 - ... - anonymous_999 Some records around each gap might be wrapped around along increase or decrease of records in middle. Then output order of anonymous defs might be changed. Numeric sort is expected to prevent such wrap-arounds. This can be implemented with `StringRef::compare_numeric()`. - ... - anonymous_99 - anonymous_100 - ... - anonymous_999 - anonymous_1000 - ... See also discussions in D145874. Differential Revision: https://reviews.llvm.org/D145874
Diffstat (limited to 'llvm/lib/TableGen')
-rw-r--r--llvm/lib/TableGen/Record.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index a3f09bd..7e0da04 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -3006,6 +3006,10 @@ std::vector<Record *> RecordKeeper::getAllDerivedDefinitions(
Defs.push_back(OneDef.second.get());
}
+ llvm::sort(Defs, [](Record *LHS, Record *RHS) {
+ return LHS->getName().compare_numeric(RHS->getName()) < 0;
+ });
+
return Defs;
}