[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
Sun Jan 24 10:35:43 PST 2021


Paul-C-Anagnostopoulos created this revision.
Paul-C-Anagnostopoulos added reviewers: lattner, dblaikie, craig.topper.
Herald added a subscriber: hiraditya.
Paul-C-Anagnostopoulos requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The DetailedRecords backend currently prints a null string record name as nothing, which is confusing. This revision prints the name as "".

  |test.td:7|
  Defm sequence: |test.td:13|
  Superclasses: C
  Fields: (none)

versus

""  |test.td:7|

  Defm sequence: |test.td:13|
  Superclasses: C
  Fields: (none)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95312

Files:
  llvm/lib/TableGen/DetailedRecordsBackend.cpp


Index: llvm/lib/TableGen/DetailedRecordsBackend.cpp
===================================================================
--- llvm/lib/TableGen/DetailedRecordsBackend.cpp
+++ llvm/lib/TableGen/DetailedRecordsBackend.cpp
@@ -104,7 +104,9 @@
 
   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.size() == 0) ? "\"\"" : Name,
                   SrcMgr.getFormattedLocationNoOffset(Rec->getLoc().front()));
     printDefms(Rec, OS);
     printSuperclasses(Rec, OS);


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


More information about the llvm-commits mailing list