[llvm] [TableGen] Support type aliases via new keyword deftype (PR #79570)

Wang Pengcheng via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 22:40:35 PST 2024


================
@@ -3665,6 +3671,42 @@ bool TGParser::ParseDefset() {
   return false;
 }
 
+/// ParseDeftype - Parse a defvar statement.
+///
+///   Deftype ::= DEFTYPE Id '=' Type ';'
+///
+bool TGParser::ParseDeftype() {
+  assert(Lex.getCode() == tgtok::Deftype);
+  Lex.Lex(); // Eat the 'deftype' token
+
+  if (Lex.getCode() != tgtok::Id)
+    return TokError("expected identifier");
+
+  std::string TypeName = Lex.getCurStrVal();
----------------
wangpc-pp wrote:

I can make it `const` but it can't be a reference. `TypeName` will be used in line 3702 and its reference string (which is a field of `Lexer`) has changed when we run to that line.

https://github.com/llvm/llvm-project/pull/79570


More information about the llvm-commits mailing list