Skip to content

Commit 1db2d57

Browse files
[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 = []; ^ ```
1 parent 37cb9bd commit 1db2d57

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/lib/TableGen/TGParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3504,7 +3504,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) {
35043504

35053505
RecordVal *Field = CurRec->getValue(FieldName);
35063506
if (!Field)
3507-
return TokError("Value '" + FieldName->getValue() + "' unknown!");
3507+
return Error(IdLoc, "Value '" + FieldName->getValue() + "' unknown!");
35083508

35093509
const RecTy *Type = Field->getType();
35103510
if (!BitList.empty() && isa<BitsRecTy>(Type)) {

llvm/test/TableGen/letUnknownValue.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: not llvm-tblgen %s 2>&1 | FileCheck %s --strict-whitespace
2+
3+
def {
4+
/// Let can only override something that already exists.
5+
let abc = [];
6+
// CHECK: error: Value 'abc' unknown!
7+
// CHECK-NEXT:{{^}} let abc = [];
8+
// CHECK-NEXT:{{^}} ^
9+
}

0 commit comments

Comments
 (0)