forked from OSchip/llvm-project
[TableGen] Fix instantiating multiclass in foreach
If multiclass argument comes from loop varaible and argument is record type, it will not recognize the type. This patch ensures that loop variables are resolved correctly. Differential Revision: https://reviews.llvm.org/D95308
This commit is contained in:
parent
d087d805ac
commit
5046c5be84
|
@ -3524,8 +3524,8 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
|
|||
|
||||
Substs.emplace_back(QualifiedNameOfImplicitName(MC), DefmName);
|
||||
|
||||
if (resolve(MC->Entries, Substs, CurMultiClass == nullptr, &NewEntries,
|
||||
&SubClassLoc))
|
||||
if (resolve(MC->Entries, Substs, !CurMultiClass && Loops.empty(),
|
||||
&NewEntries, &SubClassLoc))
|
||||
return true;
|
||||
|
||||
if (!consume(tgtok::comma))
|
||||
|
|
|
@ -57,6 +57,9 @@
|
|||
// CHECK: def F2_2_1
|
||||
// CHECK-NOT: def F2_2_2
|
||||
|
||||
// CHECK: def G0
|
||||
// CHECK: def H0_G0_0
|
||||
|
||||
multiclass A<int x> {
|
||||
foreach i = [0, 1] in {
|
||||
def NAME#i {
|
||||
|
@ -116,3 +119,20 @@ multiclass F<list<int> lst> {
|
|||
defm F0 : F<[]>;
|
||||
defm F1 : F<[0]>;
|
||||
defm F2 : F<[0, 1, 2]>;
|
||||
|
||||
// If multiclass argument comes from loop variable,
|
||||
// and field of argument is placed at foreach statement,
|
||||
// the record field must be resolved correctly.
|
||||
class G {
|
||||
list<int> val = [0];
|
||||
}
|
||||
|
||||
multiclass H<G g> {
|
||||
foreach n = g.val in
|
||||
def _#g#_#n;
|
||||
}
|
||||
|
||||
def G0 : G;
|
||||
|
||||
foreach g = [G0] in
|
||||
defm H0 : H<g>;
|
||||
|
|
Loading…
Reference in New Issue