[PATCH] D81074: [TableGen] Add error messages
Sebastian Neubauer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 03:15:44 PDT 2020
Flakebi created this revision.
Flakebi added a reviewer: dsanders.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Print an error instead of crashing in two places.
If someone has a better error message for the first case, I would be glad to use it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81074
Files:
llvm/utils/TableGen/SearchableTableEmitter.cpp
Index: llvm/utils/TableGen/SearchableTableEmitter.cpp
===================================================================
--- llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ 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<DefInit>(I)->getDef()];
+ if (!Entry)
+ PrintFatalError(Twine("entry for field '") + Field.Name + "' is null");
return std::string(
Field.Enum->EntryMap[cast<DefInit>(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<Record *> &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<TypedInit>(EntryRec->getValueInit(Field.Name));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81074.268113.patch
Type: text/x-patch
Size: 1221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200603/fb958f4e/attachment.bin>
More information about the llvm-commits
mailing list