[PATCH] D44106: TableGen: More helpful error messages

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 5 12:20:34 PST 2018


nhaehnle created this revision.
nhaehnle added reviewers: arsenm, craig.topper, tra, MartinO.
Herald added a subscriber: wdng.
nhaehnle added a dependency: D44105: TableGen: add !isa operation.
nhaehnle added a dependent revision: D44107: TableGen: Remove unused ParseForeachMode.

Change-Id: Ic78afd0cd765fdb4cf1b7ecfb6bba22653ce6d29


Repository:
  rL LLVM

https://reviews.llvm.org/D44106

Files:
  lib/TableGen/Record.cpp


Index: lib/TableGen/Record.cpp
===================================================================
--- lib/TableGen/Record.cpp
+++ lib/TableGen/Record.cpp
@@ -1835,11 +1835,19 @@
       continue;
     if (Init *V = Value.getValue()) {
       Init *VR = V->resolveReferences(R);
-      if (Value.setValue(VR))
-        PrintFatalError(getLoc(), "Invalid value is found when setting '" +
+      if (Value.setValue(VR)) {
+        std::string Type;
+        if (TypedInit *VRT = dyn_cast<TypedInit>(VR))
+          Type =
+              (Twine("of type '") + VRT->getType()->getAsString() + "' ").str();
+        PrintFatalError(getLoc(), Twine("Invalid value ") + Type +
+                                      "is found when setting '" +
                                       Value.getNameInitAsString() +
+                                      " of type '" +
+                                      Value.getType()->getAsString() +
                                       "' after resolving references: " +
                                       VR->getAsUnquotedString() + "\n");
+      }
     }
   }
   Init *OldName = getNameInit();
@@ -1969,8 +1977,10 @@
 
   if (IntInit *II = dyn_cast<IntInit>(R->getValue()))
     return II->getValue();
-  PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
-    FieldName + "' does not have an int initializer!");
+  PrintFatalError(getLoc(), Twine("Record `") + getName() + "', field `" +
+                                FieldName +
+                                "' does not have an int initializer: " +
+                                R->getValue()->getAsString());
 }
 
 std::vector<int64_t>
@@ -1981,8 +1991,10 @@
     if (IntInit *II = dyn_cast<IntInit>(I))
       Ints.push_back(II->getValue());
     else
-      PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
-        FieldName + "' does not have a list of ints initializer!");
+      PrintFatalError(getLoc(),
+                      Twine("Record `") + getName() + "', field `" + FieldName +
+                          "' does not have a list of ints initializer: " +
+                          I->getAsString());
   }
   return Ints;
 }
@@ -1995,8 +2007,10 @@
     if (StringInit *SI = dyn_cast<StringInit>(I))
       Strings.push_back(SI->getValue());
     else
-      PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
-        FieldName + "' does not have a list of strings initializer!");
+      PrintFatalError(getLoc(),
+                      Twine("Record `") + getName() + "', field `" + FieldName +
+                          "' does not have a list of strings initializer: " +
+                          I->getAsString());
   }
   return Strings;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44106.137054.patch
Type: text/x-patch
Size: 2712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180305/13a49a99/attachment.bin>


More information about the llvm-commits mailing list