Skip to content

Conversation

@DavidSpickett
Copy link
Collaborator

@DavidSpickett DavidSpickett commented Dec 4, 2024

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 = [];
      ^

Fixes llvm#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 = [];
      ^
@llvmbot
Copy link
Member

llvmbot commented Dec 4, 2024

@llvm/pr-subscribers-tablegen

Author: David Spickett (DavidSpickett)

Changes

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 = [];
      ^

Full diff: https://github.com/llvm/llvm-project/pull/118616.diff

2 Files Affected:

  • (modified) llvm/lib/TableGen/TGParser.cpp (+1-1)
  • (added) llvm/test/TableGen/letUnknownValue.td (+9)
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

Copy link
Contributor

@jurahul jurahul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DavidSpickett DavidSpickett merged commit 1db2d57 into llvm:main Dec 9, 2024
10 checks passed
@DavidSpickett DavidSpickett deleted the llvm-let branch December 9, 2024 13:21
qiaojbao pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Dec 23, 2024
Local branch amd-gfx e2fc454 Merged main:e0ea9fd6dc36 into amd-gfx:1e7037e979ae
Remote branch main 1db2d57 [llvm][TableGen] Fix misleading error for invalid use of let (llvm#118616)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TableGen "Value <name> unknown!" error does not point to the value's name

3 participants