[llvm] [NFC][TableGen] Refactor JSON and detailed record emitter (PR #105770)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 26 00:37:01 PDT 2024
================
@@ -101,40 +103,31 @@ void DetailedRecordsEmitter::printRecords(raw_ostream &OS) {
const auto &RecordList = Records.getDefs();
printSectionHeading("Records", RecordList.size(), OS);
- for (const auto &RecPair : RecordList) {
- auto *const Rec = RecPair.second.get();
+ for (const auto &[DefName, Rec] : RecordList) {
std::string Name = Rec->getNameInitAsString();
OS << formatv("\n{0} |{1}|\n", Name.empty() ? "\"\"" : Name,
SrcMgr.getFormattedLocationNoOffset(Rec->getLoc().front()));
- printDefms(Rec, OS);
- printSuperclasses(Rec, OS);
- printFields(Rec, OS);
+ printDefms(Rec.get(), OS);
+ printSuperclasses(Rec.get(), OS);
+ printFields(Rec.get(), OS);
}
}
-// Print a section heading with the name of the section and
-// the item count.
-void DetailedRecordsEmitter::printSectionHeading(StringRef Title, int Count,
- raw_ostream &OS) {
- OS << formatv("\n{0} {1} ({2}) {0}\n", "--------------------", Title, Count);
-}
-
// Print the record's defm source locations, if any. Note that they
// are stored in the reverse order of their invocation.
-void DetailedRecordsEmitter::printDefms(Record *Rec, raw_ostream &OS) {
+void DetailedRecordsEmitter::printDefms(const Record *Rec, raw_ostream &OS) {
----------------
s-barannikov wrote:
Pass `Rec` by reference?
https://github.com/llvm/llvm-project/pull/105770
More information about the llvm-commits
mailing list