diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp --- a/llvm/utils/TableGen/SearchableTableEmitter.cpp +++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp @@ -119,9 +119,13 @@ return "Intrinsic::" + getIntrinsic(I).EnumName; else if (Field.IsInstruction) return I->getAsString(); - else if (Field.Enum) + else if (Field.Enum) { + auto *Entry = Field.Enum->EntryMap[cast(I)->getDef()]; + if (!Entry) + PrintFatalError(Twine("entry for field '") + Field.Name + "' is null"); return std::string( Field.Enum->EntryMap[cast(I)->getDef()]->first); + } PrintFatalError(Twine("invalid field type for field '") + Field.Name + "', expected: string, bits, bit or code"); } @@ -596,6 +600,9 @@ void SearchableTableEmitter::collectTableEntries( GenericTable &Table, const std::vector &Items) { + if (Items.empty()) + PrintFatalError(Twine("Table '") + Table.Name + "' has no items"); + for (auto EntryRec : Items) { for (auto &Field : Table.Fields) { auto TI = dyn_cast(EntryRec->getValueInit(Field.Name));