llvm.org GIT mirror llvm / 258e822
Fix error in tablegen when either operand of !if is an empty list. !if([Something], []) would error with "No type for list". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210572 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 5 years ago
3 changed file(s) with 16 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
786786 ///
787787 /// Operation ::= XOperator ['<' Type '>'] '(' Args ')'
788788 ///
789 Init *TGParser::ParseOperation(Record *CurRec) {
789 Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) {
790790 switch (Lex.getCode()) {
791791 default:
792792 TokError("unknown operation");
10251025 }
10261026 Lex.Lex(); // eat the ','
10271027
1028 Init *MHS = ParseValue(CurRec);
1029 if (!MHS) return nullptr;
1028 Init *MHS = ParseValue(CurRec, ItemType);
1029 if (!MHS)
1030 return nullptr;
10301031
10311032 if (Lex.getCode() != tgtok::comma) {
10321033 TokError("expected ',' in ternary operator");
10341035 }
10351036 Lex.Lex(); // eat the ','
10361037
1037 Init *RHS = ParseValue(CurRec);
1038 if (!RHS) return nullptr;
1038 Init *RHS = ParseValue(CurRec, ItemType);
1039 if (!RHS)
1040 return nullptr;
10391041
10401042 if (Lex.getCode() != tgtok::r_paren) {
10411043 TokError("expected ')' in binary operator");
14451447 case tgtok::XIf:
14461448 case tgtok::XForEach:
14471449 case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')'
1448 return ParseOperation(CurRec);
1450 return ParseOperation(CurRec, ItemType);
14491451 }
14501452 }
14511453
180180 std::vector ParseRangeList();
181181 bool ParseRangePiece(std::vector &Ranges);
182182 RecTy *ParseType();
183 Init *ParseOperation(Record *CurRec);
183 Init *ParseOperation(Record *CurRec, RecTy *ItemType);
184184 RecTy *ParseOperatorType();
185185 Init *ParseObjectName(MultiClass *CurMultiClass);
186186 Record *ParseClassID();
0 // RUN: llvm-tblgen %s
1 // XFAIL: vg_leak
2
3 class C {
4 list X = !if(cond, [1, 2, 3], []);
5 list Y = !if(cond, [], [4, 5, 6]);
6 }