[llvm] a912275 - [TableGen] Diagnose undefined fields when generating searchable tables
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 06:03:59 PST 2020
Author: Jay Foad
Date: 2020-02-19T14:03:48Z
New Revision: a9122758641fc2843b38ad43368c1f5833817c39
URL: https://github.com/llvm/llvm-project/commit/a9122758641fc2843b38ad43368c1f5833817c39
DIFF: https://github.com/llvm/llvm-project/commit/a9122758641fc2843b38ad43368c1f5833817c39.diff
LOG: [TableGen] Diagnose undefined fields when generating searchable tables
Summary:
Previously TableGen would crash trying to print the undefined value as
an integer.
Change-Id: I3900071ceaa07c26acafb33bc49966d7d7a02828
Reviewers: nhaehnle
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74210
Added:
Modified:
llvm/test/TableGen/generic-tables.td
llvm/utils/TableGen/SearchableTableEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/test/TableGen/generic-tables.td b/llvm/test/TableGen/generic-tables.td
index a63e25ee1151..b374a25c4eab 100644
--- a/llvm/test/TableGen/generic-tables.td
+++ b/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 @@ def lookupCEntry : SearchIndex {
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
diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp
index 2ac34bb5079e..0c79a2a6938f 100644
--- a/llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -599,7 +599,7 @@ void SearchableTableEmitter::collectTableEntries(
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 +
More information about the llvm-commits
mailing list