[PATCH] D95312: [TableGen] [DetailedRecords] Print record name that is null string as ""

Paul C. Anagnostopoulos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 27 07:42:26 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf3449ed6073c: [TableGen] [DetailedRecords] Print record name that is null string as "" (authored by Paul-C-Anagnostopoulos).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95312/new/

https://reviews.llvm.org/D95312

Files:
  llvm/lib/TableGen/DetailedRecordsBackend.cpp
  llvm/test/TableGen/detailed-records.td


Index: llvm/test/TableGen/detailed-records.td
===================================================================
--- /dev/null
+++ llvm/test/TableGen/detailed-records.td
@@ -0,0 +1,36 @@
+// RUN: llvm-tblgen -print-detailed-records %s | FileCheck %s
+
+// This test file ensures that the DetailedRecords backend prints all
+// the global variables, classes, and records.
+
+// CHECK: ----- Global Variables
+// CHECK: Answer
+// CHECK: Greeting
+
+// CHECK: ----- Classes
+// CHECK: Class1
+// CHECK: Class2
+
+// CHECK: ----- Records
+// CHECK: ""
+// CHECK: Info
+// CHECK: Rec1
+// CHECK: anonymous_0
+
+defvar Greeting = "Hello there.";
+defvar Answer = 42;
+
+class Class1 {
+}
+
+class Class2 {
+}
+
+def : Class1;
+
+def "" : Class2;
+
+def Rec1;
+
+def Info : Class1;
+
Index: llvm/lib/TableGen/DetailedRecordsBackend.cpp
===================================================================
--- llvm/lib/TableGen/DetailedRecordsBackend.cpp
+++ llvm/lib/TableGen/DetailedRecordsBackend.cpp
@@ -104,7 +104,8 @@
 
   for (const auto &RecPair : RecordList) {
     auto *const Rec = RecPair.second.get();
-    OS << formatv("\n{0}  |{1}|\n", Rec->getNameInitAsString(),
+    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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95312.319577.patch
Type: text/x-patch
Size: 1431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210127/c9e954b1/attachment.bin>


More information about the llvm-commits mailing list