llvm.org GIT mirror llvm / ac80975
Add support for empty metadata nodes: !{}. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108259 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
4 changed file(s) with 11 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
39823982 /// ::= 'null' | TypeAndValue
39833983 bool LLParser::ParseMDNodeVector(SmallVectorImpl &Elts,
39843984 PerFunctionState *PFS) {
3985 // Check for an empty list.
3986 if (Lex.getKind() == lltok::rbrace)
3987 return false;
3988
39853989 do {
39863990 // Null is a special case since it is typeless.
39873991 if (EatIfPresent(lltok::kw_null)) {
819819 IsFunctionLocal = true;
820820 // fall-through
821821 case bitc::METADATA_NODE: {
822 if (Record.empty() || Record.size() % 2 == 1)
822 if (Record.size() % 2 == 1)
823823 return Error("Invalid METADATA_NODE record");
824824
825825 unsigned Size = Record.size();
833833 else
834834 Elts.push_back(NULL);
835835 }
836 Value *V = MDNode::getWhenValsUnresolved(Context, &Elts[0], Elts.size(),
836 Value *V = MDNode::getWhenValsUnresolved(Context,
837 Elts.data(), Elts.size(),
837838 IsFunctionLocal);
838839 IsFunctionLocal = false;
839840 MDValueList.AssignValue(V, NextMDValueNo++);
7777 /// getOperandPtr - Helper function to get the MDNodeOperand's coallocated on
7878 /// the end of the MDNode.
7979 static MDNodeOperand *getOperandPtr(MDNode *N, unsigned Op) {
80 assert(Op < N->getNumOperands() && "Invalid operand number");
80 // Use <= instead of < to permit a one-past-the-end address.
81 assert(Op <= N->getNumOperands() && "Invalid operand number");
8182 return reinterpret_cast(N+1)+Op;
8283 }
8384
99
1010 !named = !{!0}
1111 !0 = metadata !{i8** null}
12 !1 = metadata !{i8* null}
12 !1 = metadata !{i8* null, metadata !2}
13 !2 = metadata !{}