[PATCH] D59294: [TableGen] Give meaningful msg for def use in multiclass

Javed Absar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 26 03:47:49 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL356985: [TableGen] Give meaningful msg for def use in multiclass (authored by javed.absar, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D59294?vs=190399&id=192253#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59294/new/

https://reviews.llvm.org/D59294

Files:
  llvm/trunk/lib/TableGen/TGParser.cpp
  llvm/trunk/test/TableGen/MultiClass-def-fail.td


Index: llvm/trunk/test/TableGen/MultiClass-def-fail.td
===================================================================
--- llvm/trunk/test/TableGen/MultiClass-def-fail.td
+++ llvm/trunk/test/TableGen/MultiClass-def-fail.td
@@ -0,0 +1,10 @@
+// RUN: not llvm-tblgen %s 2>&1 | FileCheck %s
+// XFAIL: vg_leak
+
+// This test checks that using def instead of defm gives a meaningful error
+multiclass M2 {
+  def X;
+}
+
+// CHECK: error: Couldn't find class 'M2'. Use 'defm' if you meant to use multiclass 'M2'
+def rec1 : M2;
Index: llvm/trunk/lib/TableGen/TGParser.cpp
===================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp
+++ llvm/trunk/lib/TableGen/TGParser.cpp
@@ -536,8 +536,14 @@
   }
 
   Record *Result = Records.getClass(Lex.getCurStrVal());
-  if (!Result)
-    TokError("Couldn't find class '" + Lex.getCurStrVal() + "'");
+  if (!Result) {
+    std::string Msg("Couldn't find class '" + Lex.getCurStrVal() + "'");
+    if (MultiClasses[Lex.getCurStrVal()].get())
+      TokError(Msg + ". Use 'defm' if you meant to use multiclass '" +
+               Lex.getCurStrVal() + "'");
+    else
+      TokError(Msg);
+  }
 
   Lex.Lex();
   return Result;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59294.192253.patch
Type: text/x-patch
Size: 1219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190326/f89aca1d/attachment.bin>


More information about the llvm-commits mailing list