[llvm] e6c89e8 - [TableGen] Improve the error report of getElementAsRecord (#189302)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 03:43:52 PDT 2026
Author: Pengcheng Wang
Date: 2026-03-30T18:43:47+08:00
New Revision: e6c89e8d6ad779ac57b8b35f225f960757ef57d1
URL: https://github.com/llvm/llvm-project/commit/e6c89e8d6ad779ac57b8b35f225f960757ef57d1
DIFF: https://github.com/llvm/llvm-project/commit/e6c89e8d6ad779ac57b8b35f225f960757ef57d1.diff
LOG: [TableGen] Improve the error report of getElementAsRecord (#189302)
Added:
llvm/test/TableGen/intrinsic-arginfo-error.td
Modified:
llvm/lib/TableGen/Record.cpp
Removed:
################################################################################
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 8ad20b45f5e16..4e931209e3e7c 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -768,7 +768,8 @@ const Init *ListInit::convertInitializerTo(const RecTy *Ty) const {
const Record *ListInit::getElementAsRecord(unsigned Idx) const {
const auto *DI = dyn_cast<DefInit>(getElement(Idx));
if (!DI)
- PrintFatalError("Expected record in list!");
+ PrintFatalError("expected record type for the element with index " +
+ Twine(Idx) + " in list " + getAsString());
return DI->getDef();
}
diff --git a/llvm/test/TableGen/intrinsic-arginfo-error.td b/llvm/test/TableGen/intrinsic-arginfo-error.td
new file mode 100644
index 0000000000000..a9d30b6bec05f
--- /dev/null
+++ b/llvm/test/TableGen/intrinsic-arginfo-error.td
@@ -0,0 +1,10 @@
+// RUN: not llvm-tblgen -gen-intrinsic-enums -I %p/../../include %s 2>&1 | FileCheck %s
+
+include "llvm/IR/Intrinsics.td"
+
+// CHECK: error: expected record type for the element with index 2 in list {{.*}}
+def int_test : DefaultAttrsIntrinsic<
+ [llvm_anyint_ty],
+ [llvm_anyint_ty,
+ LLVMMatchType<2>],
+ [IntrNoMem]>;
More information about the llvm-commits
mailing list