[llvm] r214374 - Add a better error message when failing to assign one tablegen value to another

Pete Cooper peter_cooper at apple.com
Wed Jul 30 18:43:57 PDT 2014


Author: pete
Date: Wed Jul 30 20:43:57 2014
New Revision: 214374

URL: http://llvm.org/viewvc/llvm-project?rev=214374&view=rev
Log:
Add a better error message when failing to assign one tablegen value to another

This is currently for assigning from one bit init to another.  It can easily be extended to other types.

Test to follow soon in another patch.

Modified:
    llvm/trunk/lib/TableGen/TGParser.cpp

Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=214374&r1=214373&r2=214374&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Wed Jul 30 20:43:57 2014
@@ -135,11 +135,18 @@ bool TGParser::SetValue(Record *CurRec,
     V = BitsInit::get(NewBits);
   }
 
-  if (RV->setValue(V))
+  if (RV->setValue(V)) {
+    std::string InitType = "";
+    if (BitsInit *BI = dyn_cast<BitsInit>(V)) {
+      InitType = (Twine("' of type bit initializer with length ") +
+                  Twine(BI->getNumBits())).str();
+    }
     return Error(Loc, "Value '" + ValName->getAsUnquotedString() + "' of type '"
                  + RV->getType()->getAsString() +
                  "' is incompatible with initializer '" + V->getAsString()
+                 + InitType
                  + "'");
+  }
   return false;
 }
 





More information about the llvm-commits mailing list