+ // Check if the name is a complex pattern.
+ // If so, resolve it.
+ DefName = CurRec->getNameInit();
+ DefNameString = dyn_cast<StringInit>(DefName);
+
+ // OK the pattern is more complex than simply using NAME.
+ // Let's use the heavy weaponery.
+ if (!DefNameString) {
+ ResolveMulticlassDefArgs(MC, CurRec.get(), DefmPrefixRange.Start,
+ Lex.getLoc(), TArgs, TemplateVals,
+ false/*Delete args*/);
+ DefName = CurRec->getNameInit();
+ DefNameString = dyn_cast<StringInit>(DefName);
+
+ if (!DefNameString)
+ DefName = DefName->convertInitializerTo(StringRecTy::get());
+
+ // We ran out of options here...
+ DefNameString = dyn_cast<StringInit>(DefName);
+ if (!DefNameString) {
+ PrintFatalError(CurRec->getLoc()[CurRec->getLoc().size() - 1],
+ DefName->getAsUnquotedString() + " is not a string.");
+ return nullptr;
+ }
+
+ CurRec->setName(DefName);
+ }
+