[PATCH] D74210: [TableGen] Diagnose undefined fields when generating searchable tables
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 7 03:23:40 PST 2020
foad created this revision.
foad added a reviewer: nhaehnle.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Previously TableGen would crash trying to print the undefined value as
an integer.
Change-Id: I3900071ceaa07c26acafb33bc49966d7d7a02828
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74210
Files:
llvm/test/TableGen/generic-tables.td
llvm/utils/TableGen/SearchableTableEmitter.cpp
Index: llvm/utils/TableGen/SearchableTableEmitter.cpp
===================================================================
--- llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -599,7 +599,7 @@
for (auto EntryRec : Items) {
for (auto &Field : Table.Fields) {
auto TI = dyn_cast<TypedInit>(EntryRec->getValueInit(Field.Name));
- if (!TI) {
+ if (!TI || !TI->isComplete()) {
PrintFatalError(EntryRec->getLoc(),
Twine("Record '") + EntryRec->getName() +
"' in table '" + Table.Name +
Index: llvm/test/TableGen/generic-tables.td
===================================================================
--- llvm/test/TableGen/generic-tables.td
+++ llvm/test/TableGen/generic-tables.td
@@ -1,4 +1,5 @@
// RUN: llvm-tblgen -gen-searchable-tables -I %p/../../include %s | FileCheck %s
+// RUN: not llvm-tblgen -gen-searchable-tables -I %p/../../include -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
// XFAIL: vg_leak
include "llvm/TableGen/SearchableTable.td"
@@ -136,3 +137,21 @@
let Table = CTable;
let Key = ["Name", "Kind"];
}
+
+#ifdef ERROR1
+
+class DEntry<string str, int val1> {
+ string Str = str;
+ bits<8> Val1 = val1;
+}
+
+def DFoo : DEntry<"foo", 1>;
+// ERROR1: [[@LINE+1]]:1: error: Record 'DBar' in table 'DTable' is missing field 'Val1'
+def DBar : DEntry<"bar", ?>;
+
+def DTable : GenericTable {
+ let FilterClass = "DEntry";
+ let Fields = ["Str", "Val1"];
+}
+
+#endif // ERROR1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74210.243125.patch
Type: text/x-patch
Size: 1551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200207/5bfa3ea3/attachment.bin>
More information about the llvm-commits
mailing list