Index: llvm/lib/TableGen/TGParser.cpp =================================================================== --- llvm/lib/TableGen/TGParser.cpp +++ llvm/lib/TableGen/TGParser.cpp @@ -3509,7 +3509,20 @@ SubstStack Substs; for (unsigned i = 0, e = TArgs.size(); i != e; ++i) { if (i < TemplateVals.size()) { + // This if block is a hack so we can track down multiclass template + // argument values of the wrong type. + if (TypedInit *ArgValue = dyn_cast(TemplateVals[i])) { + auto *ArgType = MC->Rec.getValue(TArgs[i])->getType(); + if (!ArgValue->getCastTo(ArgType)) + return Error(SubClassLoc, + "Value specified for template argument '" + + TArgs[i]->getAsString() + "' (#" + Twine(i) + + ") is of type " + ArgValue->getType()->getAsString() + + "; expected type " + ArgType->getAsString() + ": " + + ArgValue->getAsString()); + } Substs.emplace_back(TArgs[i], TemplateVals[i]); + } else { Init *Default = MC->Rec.getValue(TArgs[i])->getValue(); if (!Default->isComplete()) {