[llvm] 107189a - [TableGen] Report an error message on a missing comma
Alex Richardson via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 9 10:50:34 PDT 2021
Author: Alex Richardson
Date: 2021-04-09T18:48:49+01:00
New Revision: 107189a26eef0e6aef19b1bad4a3349d6207ac32
URL: https://github.com/llvm/llvm-project/commit/107189a26eef0e6aef19b1bad4a3349d6207ac32
DIFF: https://github.com/llvm/llvm-project/commit/107189a26eef0e6aef19b1bad4a3349d6207ac32.diff
LOG: [TableGen] Report an error message on a missing comma
I recently forgot a comma in a defm argument list and tablegen just
failed with exit code 1 without printing an error message. I believe
this issue was introduced in a9fc44c5573208859c2550382755098d750fc47d.
This change prints the following instead:
.../clang/include/clang/Driver/Options.td:569:3: error: Expected comma before next argument
Reviewed By: Paul-C-Anagnostopoulos
Differential Revision: https://reviews.llvm.org/D100178
Added:
Modified:
llvm/lib/TableGen/TGParser.cpp
llvm/test/TableGen/template-args.td
Removed:
################################################################################
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index 3d95ac30ebd0b..fa255ac27344f 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -2539,9 +2539,9 @@ bool TGParser::ParseTemplateArgValueList(SmallVectorImpl<Init *> &Result,
if (consume(tgtok::greater)) // end of argument list?
return false;
- if (!consume(tgtok::comma)) // must be comma
- return true;
- ++ArgIndex;
+ if (!consume(tgtok::comma))
+ return TokError("Expected comma before next argument");
+ ++ArgIndex;
}
}
diff --git a/llvm/test/TableGen/template-args.td b/llvm/test/TableGen/template-args.td
index 2a931adffe9ad..eeba513087017 100644
--- a/llvm/test/TableGen/template-args.td
+++ b/llvm/test/TableGen/template-args.td
@@ -5,6 +5,7 @@
// RUN: not llvm-tblgen -DERROR4 %s 2>&1 | FileCheck --check-prefix=ERROR4 %s
// RUN: not llvm-tblgen -DERROR5 %s 2>&1 | FileCheck --check-prefix=ERROR5 %s
// RUN: not llvm-tblgen -DERROR6 %s 2>&1 | FileCheck --check-prefix=ERROR6 %s
+// RUN: not llvm-tblgen -DERROR7 %s 2>&1 | FileCheck --check-prefix=ERROR7 %s
// This file tests that template arguments are type-checked and cast
// if necessary.
@@ -140,3 +141,13 @@ defm RecMC3 : MC2<42>;
defm RecMC4 : MC2<"Bob">;
#endif
+
+#ifdef ERROR7
+multiclass TwoArgs<bits<8> a, string b> {
+ def _1 { bits<8> A = a; }
+ def _2 { string B = b; }
+}
+defm Good : TwoArgs<1, "one">;
+defm MissingComma : TwoArgs<2 "two">;
+// ERROR7: [[#@LINE-1]]:31: error: Expected comma before next argument
+#endif
More information about the llvm-commits
mailing list