llvm.org GIT mirror llvm / 2214dc0
Fix pr5470. Tablegen handles template arguments by temporarily setting their values, resolving references to them, and then removing the definitions. If a template argument is set to an undefined value, we need to resolve references to that argument to an explicit undefined value. The current code leaves the reference to the template argument as it is, which causes an assertion failure later when the definition of the template argument is removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89581 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 9 years ago
2 changed file(s) with 30 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
0 // RUN: tblgen %s
1 class x {
2 field bits<32> A;
3 }
4
5 class y B> : x {
6 let A{21-20} = B;
7 }
8
9 def z : y<{0,?}>;
489489 if (Elt >= getSize())
490490 return 0; // Out of range reference.
491491 Init *E = getElement(Elt);
492 if (!dynamic_cast(E)) // If the element is set
493 return E; // Replace the VarListElementInit with it.
492 // If the element is set to some value, or if we are resolving a reference
493 // to a specific variable and that variable is explicitly unset, then
494 // replace the VarListElementInit with it.
495 if (IRV || !dynamic_cast(E))
496 return E;
494497 return 0;
495498 }
496499
11151118 assert(Bit < BI->getNumBits() && "Bit reference out of range!");
11161119 Init *B = BI->getBit(Bit);
11171120
1118 if (!dynamic_cast(B)) // If the bit is not set...
1119 return B; // Replace the VarBitInit with it.
1121 // If the bit is set to some value, or if we are resolving a reference to a
1122 // specific variable and that variable is explicitly unset, then replace the
1123 // VarBitInit with it.
1124 if (IRV || !dynamic_cast(B))
1125 return B;
11201126 return 0;
11211127 }
11221128
11371143 if (Elt >= LI->getSize())
11381144 return 0; // Out of range reference.
11391145 Init *E = LI->getElement(Elt);
1140 if (!dynamic_cast(E)) // If the element is set
1141 return E; // Replace the VarListElementInit with it.
1146 // If the element is set to some value, or if we are resolving a reference
1147 // to a specific variable and that variable is explicitly unset, then
1148 // replace the VarListElementInit with it.
1149 if (IRV || !dynamic_cast(E))
1150 return E;
11421151 return 0;
11431152 }
11441153
12451254 if (Elt >= LI->getSize()) return 0;
12461255 Init *E = LI->getElement(Elt);
12471256
1248 if (!dynamic_cast(E)) // If the bit is set...
1249 return E; // Replace the VarListElementInit with it.
1257 // If the element is set to some value, or if we are resolving a
1258 // reference to a specific variable and that variable is explicitly
1259 // unset, then replace the VarListElementInit with it.
1260 if (RV || !dynamic_cast(E))
1261 return E;
12501262 }
12511263 return 0;
12521264 }