[PATCH] D81074: [TableGen] Add error messages

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 23 03:08:45 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd668d8b61975: [TableGen] Add error messages (authored by sebastian-ne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81074

Files:
  llvm/utils/TableGen/SearchableTableEmitter.cpp


Index: llvm/utils/TableGen/SearchableTableEmitter.cpp
===================================================================
--- llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -119,9 +119,12 @@
       return "Intrinsic::" + getIntrinsic(I).EnumName;
     else if (Field.IsInstruction)
       return I->getAsString();
-    else if (Field.Enum)
-      return std::string(
-          Field.Enum->EntryMap[cast<DefInit>(I)->getDef()]->first);
+    else if (Field.Enum) {
+      auto *Entry = Field.Enum->EntryMap[cast<DefInit>(I)->getDef()];
+      if (!Entry)
+        PrintFatalError(Twine("Entry for field '") + Field.Name + "' is null");
+      return std::string(Entry->first);
+    }
     PrintFatalError(Twine("invalid field type for field '") + Field.Name +
                     "', expected: string, bits, bit or code");
   }
@@ -596,6 +599,9 @@
 
 void SearchableTableEmitter::collectTableEntries(
     GenericTable &Table, const std::vector<Record *> &Items) {
+  if (Items.empty())
+    PrintWarning(Twine("Table '") + Table.Name + "' has no items");
+
   for (auto EntryRec : Items) {
     for (auto &Field : Table.Fields) {
       auto TI = dyn_cast<TypedInit>(EntryRec->getValueInit(Field.Name));
@@ -624,6 +630,10 @@
   Record *IntrinsicClass = Records.getClass("Intrinsic");
   Record *InstructionClass = Records.getClass("Instruction");
   for (auto &Field : Table.Fields) {
+    if (!Field.RecType)
+      PrintFatalError(Twine("Cannot determine type of field '") + Field.Name +
+                      "' in table '" + Table.Name + "'. Maybe it is not used?");
+
     if (auto RecordTy = dyn_cast<RecordRecTy>(Field.RecType)) {
       if (IntrinsicClass && RecordTy->isSubClassOf(IntrinsicClass))
         Field.IsIntrinsic = true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81074.272658.patch
Type: text/x-patch
Size: 1798 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200623/47f20edd/attachment-0001.bin>


More information about the llvm-commits mailing list