diff options
author | wangpc <pc.wang@linux.alibaba.com> | 2023-04-14 11:07:29 +0800 |
---|---|---|
committer | wangpc <pc.wang@linux.alibaba.com> | 2023-04-14 11:12:35 +0800 |
commit | fd5d0a88dde007728004e43cb28f3c8c0be7b97c (patch) | |
tree | 10a56fb1753b55cc23392475efc8764247322370 /llvm/lib/TableGen/TGParser.cpp | |
parent | 99e52b68a4a02acf098b48bf6749badcac55d37e (diff) | |
download | llvm-fd5d0a88dde007728004e43cb28f3c8c0be7b97c.zip llvm-fd5d0a88dde007728004e43cb28f3c8c0be7b97c.tar.gz llvm-fd5d0a88dde007728004e43cb28f3c8c0be7b97c.tar.bz2 |
[TableGen] Allow references to class template arguments in defvar
We can't refer to template arguments for defvar statements in class
definitions, or it will report some errors like:
```
error: Variable not defined: 'xxx'.
```
The key point here is we used to pass nullptr to `ParseValue` in
`ParseDefvar`. As a result, we can't refer to template arguments
since `CurRec` is nullptr in `ParseIDValue`.
So we add an argument `CurRec` to `ParseDefvar` and provide it
when parsing defvar statements in class definitions.
Reviewed By: tra, simon_tatham
Differential Revision: https://reviews.llvm.org/D148197
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
-rw-r--r-- | llvm/lib/TableGen/TGParser.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index 6c52edc..14c529c 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -3023,7 +3023,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) { return ParseAssert(nullptr, CurRec); if (Lex.getCode() == tgtok::Defvar) - return ParseDefvar(); + return ParseDefvar(CurRec); if (Lex.getCode() != tgtok::Let) { if (!ParseDeclaration(CurRec, false)) @@ -3254,7 +3254,7 @@ bool TGParser::ParseDefset() { /// /// Defvar ::= DEFVAR Id '=' Value ';' /// -bool TGParser::ParseDefvar() { +bool TGParser::ParseDefvar(Record *CurRec) { assert(Lex.getCode() == tgtok::Defvar); Lex.Lex(); // Eat the 'defvar' token @@ -3273,7 +3273,7 @@ bool TGParser::ParseDefvar() { if (!consume(tgtok::equal)) return TokError("expected '='"); - Init *Value = ParseValue(nullptr); + Init *Value = ParseValue(CurRec); if (!Value) return true; |