[llvm] 1db2d57 - [llvm][TableGen] Fix misleading error for invalid use of let (#118616)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 9 05:21:50 PST 2024
Author: David Spickett
Date: 2024-12-09T13:21:46Z
New Revision: 1db2d571b501851d7c0b72c61a7ba9e30f6db5ea
URL: https://github.com/llvm/llvm-project/commit/1db2d571b501851d7c0b72c61a7ba9e30f6db5ea
DIFF: https://github.com/llvm/llvm-project/commit/1db2d571b501851d7c0b72c61a7ba9e30f6db5ea.diff
LOG: [llvm][TableGen] Fix misleading error for invalid use of let (#118616)
Fixes #118490
Point to the value name, otherwise it implies that the part after the
'=' is the problem.
Before:
```
/tmp/test.td:2:27: error: Value 'FlattenedFeatures' unknown!
let FlattenedFeatures = [];
^
```
After:
```
/tmp/test.td:2:7: error: Value 'FlattenedFeatures' unknown!
let FlattenedFeatures = [];
^
```
Added:
llvm/test/TableGen/letUnknownValue.td
Modified:
llvm/lib/TableGen/TGParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index e01342ffcd3c8f..8a8cd2b7356cd3 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -3504,7 +3504,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) {
RecordVal *Field = CurRec->getValue(FieldName);
if (!Field)
- return TokError("Value '" + FieldName->getValue() + "' unknown!");
+ return Error(IdLoc, "Value '" + FieldName->getValue() + "' unknown!");
const RecTy *Type = Field->getType();
if (!BitList.empty() && isa<BitsRecTy>(Type)) {
diff --git a/llvm/test/TableGen/letUnknownValue.td b/llvm/test/TableGen/letUnknownValue.td
new file mode 100644
index 00000000000000..e33dca417f1d1d
--- /dev/null
+++ b/llvm/test/TableGen/letUnknownValue.td
@@ -0,0 +1,9 @@
+// RUN: not llvm-tblgen %s 2>&1 | FileCheck %s --strict-whitespace
+
+def {
+ /// Let can only override something that already exists.
+ let abc = [];
+// CHECK: error: Value 'abc' unknown!
+// CHECK-NEXT:{{^}} let abc = [];
+// CHECK-NEXT:{{^}} ^
+}
\ No newline at end of file
More information about the llvm-commits
mailing list