X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAsmParser%2FLLParser.cpp;h=a1f70fb0249ceee5de67efcf22c79701009241f7;hb=867fe8570f299a058f155f98646d85cabc27155b;hp=1cd66e536ea788c990114aec04698b0a54b182ed;hpb=07d317711781d8c9268f7d6afcf1ba7eadf1d127;p=oota-llvm.git diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 1cd66e536ea..a1f70fb0249 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -22,7 +22,6 @@ #include "llvm/Operator.h" #include "llvm/ValueSymbolTable.h" #include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -52,7 +51,7 @@ bool LLParser::ValidateEndOfModule() { if (SlotNo >= NumberedMetadata.size() || NumberedMetadata[SlotNo] == 0) return Error(MDList[i].Loc, "use of undefined metadata '!" + - utostr(SlotNo) + "'"); + Twine(SlotNo) + "'"); Inst->setMetadata(MDList[i].MDKind, NumberedMetadata[SlotNo]); } } @@ -109,7 +108,7 @@ bool LLParser::ValidateEndOfModule() { if (!ForwardRefTypeIDs.empty()) return Error(ForwardRefTypeIDs.begin()->second.second, "use of undefined type '%" + - utostr(ForwardRefTypeIDs.begin()->first) + "'"); + Twine(ForwardRefTypeIDs.begin()->first) + "'"); if (!ForwardRefVals.empty()) return Error(ForwardRefVals.begin()->second.second, @@ -119,12 +118,12 @@ bool LLParser::ValidateEndOfModule() { if (!ForwardRefValIDs.empty()) return Error(ForwardRefValIDs.begin()->second.second, "use of undefined value '@" + - utostr(ForwardRefValIDs.begin()->first) + "'"); + Twine(ForwardRefValIDs.begin()->first) + "'"); if (!ForwardRefMDNodes.empty()) return Error(ForwardRefMDNodes.begin()->second.second, "use of undefined metadata '!" + - utostr(ForwardRefMDNodes.begin()->first) + "'"); + Twine(ForwardRefMDNodes.begin()->first) + "'"); // Look for intrinsic functions and CallInst that need to be upgraded @@ -196,19 +195,21 @@ bool LLParser::ParseTopLevelEntities() { // optional leading prefixes, the production is: // GlobalVar ::= OptionalLinkage OptionalVisibility OptionalThreadLocal // OptionalAddrSpace ('constant'|'global') ... - case lltok::kw_private : // OptionalLinkage - case lltok::kw_linker_private: // OptionalLinkage - case lltok::kw_internal: // OptionalLinkage - case lltok::kw_weak: // OptionalLinkage - case lltok::kw_weak_odr: // OptionalLinkage - case lltok::kw_linkonce: // OptionalLinkage - case lltok::kw_linkonce_odr: // OptionalLinkage - case lltok::kw_appending: // OptionalLinkage - case lltok::kw_dllexport: // OptionalLinkage - case lltok::kw_common: // OptionalLinkage - case lltok::kw_dllimport: // OptionalLinkage - case lltok::kw_extern_weak: // OptionalLinkage - case lltok::kw_external: { // OptionalLinkage + case lltok::kw_private: // OptionalLinkage + case lltok::kw_linker_private: // OptionalLinkage + case lltok::kw_linker_private_weak: // OptionalLinkage + case lltok::kw_linker_private_weak_def_auto: // OptionalLinkage + case lltok::kw_internal: // OptionalLinkage + case lltok::kw_weak: // OptionalLinkage + case lltok::kw_weak_odr: // OptionalLinkage + case lltok::kw_linkonce: // OptionalLinkage + case lltok::kw_linkonce_odr: // OptionalLinkage + case lltok::kw_appending: // OptionalLinkage + case lltok::kw_dllexport: // OptionalLinkage + case lltok::kw_common: // OptionalLinkage + case lltok::kw_dllimport: // OptionalLinkage + case lltok::kw_extern_weak: // OptionalLinkage + case lltok::kw_external: { // OptionalLinkage unsigned Linkage, Visibility; if (ParseOptionalLinkage(Linkage) || ParseOptionalVisibility(Visibility) || @@ -315,7 +316,7 @@ bool LLParser::ParseUnnamedType() { if (Lex.getKind() == lltok::LocalVarID) { if (Lex.getUIntVal() != TypeID) return Error(Lex.getLoc(), "type expected to be numbered '%" + - utostr(TypeID) + "'"); + Twine(TypeID) + "'"); Lex.Lex(); // eat LocalVarID; if (ParseToken(lltok::equal, "expected '=' after name")) @@ -442,7 +443,7 @@ bool LLParser::ParseUnnamedGlobal() { if (Lex.getKind() == lltok::GlobalID) { if (Lex.getUIntVal() != VarID) return Error(Lex.getLoc(), "variable expected to be numbered '%" + - utostr(VarID) + "'"); + Twine(VarID) + "'"); Lex.Lex(); // eat GlobalID; if (ParseToken(lltok::equal, "expected '=' after name")) @@ -516,11 +517,7 @@ bool LLParser::ParseMDNodeID(MDNode *&Result) { if (Result) return false; // Otherwise, create MDNode forward reference. - - // FIXME: This is not unique enough! - std::string FwdRefName = "llvm.mdnode.fwdref." + utostr(MID); - Value *V = MDString::get(Context, FwdRefName); - MDNode *FwdNode = MDNode::get(Context, &V, 1); + MDNode *FwdNode = MDNode::getTemporary(Context, 0, 0); ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc()); if (NumberedMetadata.size() <= MID) @@ -542,26 +539,20 @@ bool LLParser::ParseNamedMetadata() { ParseToken(lltok::lbrace, "Expected '{' here")) return true; - SmallVector Elts; - do { - // Null is a special case since it is typeless. - if (EatIfPresent(lltok::kw_null)) { - Elts.push_back(0); - continue; - } - - if (ParseToken(lltok::exclaim, "Expected '!' here")) - return true; + NamedMDNode *NMD = M->getOrInsertNamedMetadata(Name); + if (Lex.getKind() != lltok::rbrace) + do { + if (ParseToken(lltok::exclaim, "Expected '!' here")) + return true; - MDNode *N = 0; - if (ParseMDNodeID(N)) return true; - Elts.push_back(N); - } while (EatIfPresent(lltok::comma)); + MDNode *N = 0; + if (ParseMDNodeID(N)) return true; + NMD->addOperand(N); + } while (EatIfPresent(lltok::comma)); if (ParseToken(lltok::rbrace, "expected end of metadata node")) return true; - NamedMDNode::Create(Context, Name, Elts.data(), Elts.size(), M); return false; } @@ -590,7 +581,9 @@ bool LLParser::ParseStandaloneMetadata() { std::map, LocTy> >::iterator FI = ForwardRefMDNodes.find(MetadataID); if (FI != ForwardRefMDNodes.end()) { - FI->second.first->replaceAllUsesWith(Init); + MDNode *Temp = FI->second.first; + Temp->replaceAllUsesWith(Init); + MDNode::deleteTemporary(Temp); ForwardRefMDNodes.erase(FI); assert(NumberedMetadata[MetadataID] == Init && "Tracking VH didn't work"); @@ -629,7 +622,9 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc, Linkage != GlobalValue::WeakODRLinkage && Linkage != GlobalValue::InternalLinkage && Linkage != GlobalValue::PrivateLinkage && - Linkage != GlobalValue::LinkerPrivateLinkage) + Linkage != GlobalValue::LinkerPrivateLinkage && + Linkage != GlobalValue::LinkerPrivateWeakLinkage && + Linkage != GlobalValue::LinkerPrivateWeakDefAutoLinkage) return Error(LinkageLoc, "invalid linkage type for alias"); Constant *Aliasee; @@ -680,7 +675,7 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc, // Insert into the module, we know its name won't collide now. M->getAliasList().push_back(GA); - assert(GA->getNameStr() == Name && "Should not be a name conflict!"); + assert(GA->getName() == Name && "Should not be a name conflict!"); return false; } @@ -859,7 +854,7 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc) { // If we have the value in the symbol table or fwd-ref table, return it. if (Val) { if (Val->getType() == Ty) return Val; - Error(Loc, "'@" + utostr(ID) + "' defined with type '" + + Error(Loc, "'@" + Twine(ID) + "' defined with type '" + Val->getType()->getDescription() + "'"); return 0; } @@ -987,6 +982,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) { case lltok::kw_noredzone: Attrs |= Attribute::NoRedZone; break; case lltok::kw_noimplicitfloat: Attrs |= Attribute::NoImplicitFloat; break; case lltok::kw_naked: Attrs |= Attribute::Naked; break; + case lltok::kw_hotpatch: Attrs |= Attribute::Hotpatch; break; case lltok::kw_alignstack: { unsigned Alignment; @@ -1013,11 +1009,14 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) { /// ::= /*empty*/ /// ::= 'private' /// ::= 'linker_private' +/// ::= 'linker_private_weak' +/// ::= 'linker_private_weak_def_auto' /// ::= 'internal' /// ::= 'weak' /// ::= 'weak_odr' /// ::= 'linkonce' /// ::= 'linkonce_odr' +/// ::= 'available_externally' /// ::= 'appending' /// ::= 'dllexport' /// ::= 'common' @@ -1030,6 +1029,12 @@ bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) { default: Res=GlobalValue::ExternalLinkage; return false; case lltok::kw_private: Res = GlobalValue::PrivateLinkage; break; case lltok::kw_linker_private: Res = GlobalValue::LinkerPrivateLinkage; break; + case lltok::kw_linker_private_weak: + Res = GlobalValue::LinkerPrivateWeakLinkage; + break; + case lltok::kw_linker_private_weak_def_auto: + Res = GlobalValue::LinkerPrivateWeakDefAutoLinkage; + break; case lltok::kw_internal: Res = GlobalValue::InternalLinkage; break; case lltok::kw_weak: Res = GlobalValue::WeakAnyLinkage; break; case lltok::kw_weak_odr: Res = GlobalValue::WeakODRLinkage; break; @@ -1079,6 +1084,8 @@ bool LLParser::ParseOptionalVisibility(unsigned &Res) { /// ::= 'arm_aapcscc' /// ::= 'arm_aapcs_vfpcc' /// ::= 'msp430_intrcc' +/// ::= 'ptx_kernel' +/// ::= 'ptx_device' /// ::= 'cc' UINT /// bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) { @@ -1094,6 +1101,8 @@ bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) { case lltok::kw_arm_aapcscc: CC = CallingConv::ARM_AAPCS; break; case lltok::kw_arm_aapcs_vfpcc:CC = CallingConv::ARM_AAPCS_VFP; break; case lltok::kw_msp430_intrcc: CC = CallingConv::MSP430_INTR; break; + case lltok::kw_ptx_kernel: CC = CallingConv::PTX_Kernel; break; + case lltok::kw_ptx_device: CC = CallingConv::PTX_Device; break; case lltok::kw_cc: { unsigned ArbitraryCC; Lex.Lex(); @@ -1112,29 +1121,44 @@ bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) { /// ParseInstructionMetadata /// ::= !dbg !42 (',' !dbg !57)* -bool LLParser::ParseInstructionMetadata(Instruction *Inst) { +bool LLParser::ParseInstructionMetadata(Instruction *Inst, + PerFunctionState *PFS) { do { if (Lex.getKind() != lltok::MetadataVar) return TokError("expected metadata after comma"); std::string Name = Lex.getStrVal(); + unsigned MDK = M->getMDKindID(Name.c_str()); Lex.Lex(); MDNode *Node; - unsigned NodeID; SMLoc Loc = Lex.getLoc(); - if (ParseToken(lltok::exclaim, "expected '!' here") || - ParseMDNodeID(Node, NodeID)) + + if (ParseToken(lltok::exclaim, "expected '!' here")) return true; - unsigned MDK = M->getMDKindID(Name.c_str()); - if (Node) { - // If we got the node, add it to the instruction. - Inst->setMetadata(MDK, Node); + // This code is similar to that of ParseMetadataValue, however it needs to + // have special-case code for a forward reference; see the comments on + // ForwardRefInstMetadata for details. Also, MDStrings are not supported + // at the top level here. + if (Lex.getKind() == lltok::lbrace) { + ValID ID; + if (ParseMetadataListValue(ID, PFS)) + return true; + assert(ID.Kind == ValID::t_MDNode); + Inst->setMetadata(MDK, ID.MDNodeVal); } else { - MDRef R = { Loc, MDK, NodeID }; - // Otherwise, remember that this should be resolved later. - ForwardRefInstMetadata[Inst].push_back(R); + unsigned NodeID = 0; + if (ParseMDNodeID(Node, NodeID)) + return true; + if (Node) { + // If we got the node, add it to the instruction. + Inst->setMetadata(MDK, Node); + } else { + MDRef R = { Loc, MDK, NodeID }; + // Otherwise, remember that this should be resolved later. + ForwardRefInstMetadata[Inst].push_back(R); + } } // If this is the end of the list, we're done. @@ -1153,6 +1177,8 @@ bool LLParser::ParseOptionalAlignment(unsigned &Alignment) { if (ParseUInt32(Alignment)) return true; if (!isPowerOf2_32(Alignment)) return Error(AlignLoc, "alignment is not a power of two"); + if (Alignment > Value::MaximumAlignment) + return Error(AlignLoc, "huge alignments are not supported yet"); return false; } @@ -1174,7 +1200,7 @@ bool LLParser::ParseOptionalCommaAlign(unsigned &Alignment, if (Lex.getKind() != lltok::kw_align) return Error(Lex.getLoc(), "expected metadata or 'align'"); - + if (ParseOptionalAlignment(Alignment)) return true; } @@ -1222,7 +1248,7 @@ bool LLParser::ParseIndexList(SmallVectorImpl &Indices, AteExtraComma = true; return false; } - unsigned Idx; + unsigned Idx = 0; if (ParseUInt32(Idx)) return true; Indices.push_back(Idx); } @@ -1336,11 +1362,6 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) { if (ParseStructType(Result, false)) return true; break; - case lltok::kw_union: - // TypeRec ::= 'union' '{' ... '}' - if (ParseUnionType(Result)) - return true; - break; case lltok::lsquare: // TypeRec ::= '[' ... ']' Lex.Lex(); // eat the lsquare. @@ -1650,38 +1671,6 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) { return false; } -/// ParseUnionType -/// TypeRec -/// ::= 'union' '{' TypeRec (',' TypeRec)* '}' -bool LLParser::ParseUnionType(PATypeHolder &Result) { - assert(Lex.getKind() == lltok::kw_union); - Lex.Lex(); // Consume the 'union' - - if (ParseToken(lltok::lbrace, "'{' expected after 'union'")) return true; - - SmallVector ParamsList; - do { - LocTy EltTyLoc = Lex.getLoc(); - if (ParseTypeRec(Result)) return true; - ParamsList.push_back(Result); - - if (Result->isVoidTy()) - return Error(EltTyLoc, "union element can not have void type"); - if (!UnionType::isValidElementType(Result)) - return Error(EltTyLoc, "invalid element type for union"); - - } while (EatIfPresent(lltok::comma)) ; - - if (ParseToken(lltok::rbrace, "expected '}' at end of union")) - return true; - - SmallVector ParamsListTy; - for (unsigned i = 0, e = ParamsList.size(); i != e; ++i) - ParamsListTy.push_back(ParamsList[i].get()); - Result = HandleUpRefs(UnionType::get(&ParamsListTy[0], ParamsListTy.size())); - return false; -} - /// ParseArrayVectorType - Parse an array or vector type, assuming the first /// token has already been consumed. /// TypeRec @@ -1792,7 +1781,7 @@ bool LLParser::PerFunctionState::FinishFunction() { if (!ForwardRefValIDs.empty()) return P.Error(ForwardRefValIDs.begin()->second.second, "use of undefined value '%" + - utostr(ForwardRefValIDs.begin()->first) + "'"); + Twine(ForwardRefValIDs.begin()->first) + "'"); return false; } @@ -1860,9 +1849,9 @@ Value *LLParser::PerFunctionState::GetVal(unsigned ID, const Type *Ty, if (Val) { if (Val->getType() == Ty) return Val; if (Ty->isLabelTy()) - P.Error(Loc, "'%" + utostr(ID) + "' is not a basic block"); + P.Error(Loc, "'%" + Twine(ID) + "' is not a basic block"); else - P.Error(Loc, "'%" + utostr(ID) + "' defined with type '" + + P.Error(Loc, "'%" + Twine(ID) + "' defined with type '" + Val->getType()->getDescription() + "'"); return 0; } @@ -1904,7 +1893,7 @@ bool LLParser::PerFunctionState::SetInstName(int NameID, if (unsigned(NameID) != NumberedVals.size()) return P.Error(NameLoc, "instruction expected to be numbered '%" + - utostr(NumberedVals.size()) + "'"); + Twine(NumberedVals.size()) + "'"); std::map >::iterator FI = ForwardRefValIDs.find(NameID); @@ -1936,7 +1925,7 @@ bool LLParser::PerFunctionState::SetInstName(int NameID, // Set the name on the instruction. Inst->setName(NameStr); - if (Inst->getNameStr() != NameStr) + if (Inst->getName() != NameStr) return P.Error(NameLoc, "multiple definition of local value named '" + NameStr + "'"); return false; @@ -2014,33 +2003,8 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) { ID.StrVal = Lex.getStrVal(); ID.Kind = ValID::t_LocalName; break; - case lltok::exclaim: // !{...} MDNode, !"foo" MDString - Lex.Lex(); - - if (EatIfPresent(lltok::lbrace)) { - SmallVector Elts; - if (ParseMDNodeVector(Elts, PFS) || - ParseToken(lltok::rbrace, "expected end of metadata node")) - return true; - - ID.MDNodeVal = MDNode::get(Context, Elts.data(), Elts.size()); - ID.Kind = ValID::t_MDNode; - return false; - } - - // Standalone metadata reference - // !{ ..., !42, ... } - if (Lex.getKind() == lltok::APSInt) { - if (ParseMDNodeID(ID.MDNodeVal)) return true; - ID.Kind = ValID::t_MDNode; - return false; - } - - // MDString: - // ::= '!' STRINGCONSTANT - if (ParseMDString(ID.MDStringVal)) return true; - ID.Kind = ValID::t_MDString; - return false; + case lltok::exclaim: // !42, !{...}, or !"foo" + return ParseMetadataValue(ID, PFS); case lltok::APSInt: ID.APSIntVal = Lex.getAPSIntVal(); ID.Kind = ValID::t_APSInt; @@ -2107,7 +2071,7 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) { for (unsigned i = 1, e = Elts.size(); i != e; ++i) if (Elts[i]->getType() != Elts[0]->getType()) return Error(FirstEltLoc, - "vector element #" + utostr(i) + + "vector element #" + Twine(i) + " is not of type '" + Elts[0]->getType()->getDescription()); ID.ConstantVal = ConstantVector::get(Elts.data(), Elts.size()); @@ -2140,7 +2104,7 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) { for (unsigned i = 0, e = Elts.size(); i != e; ++i) { if (Elts[i]->getType() != Elts[0]->getType()) return Error(FirstEltLoc, - "array element #" + utostr(i) + + "array element #" + Twine(i) + " is not of type '" +Elts[0]->getType()->getDescription()); } @@ -2521,6 +2485,48 @@ bool LLParser::ParseGlobalValueVector(SmallVectorImpl &Elts) { return false; } +bool LLParser::ParseMetadataListValue(ValID &ID, PerFunctionState *PFS) { + assert(Lex.getKind() == lltok::lbrace); + Lex.Lex(); + + SmallVector Elts; + if (ParseMDNodeVector(Elts, PFS) || + ParseToken(lltok::rbrace, "expected end of metadata node")) + return true; + + ID.MDNodeVal = MDNode::get(Context, Elts.data(), Elts.size()); + ID.Kind = ValID::t_MDNode; + return false; +} + +/// ParseMetadataValue +/// ::= !42 +/// ::= !{...} +/// ::= !"string" +bool LLParser::ParseMetadataValue(ValID &ID, PerFunctionState *PFS) { + assert(Lex.getKind() == lltok::exclaim); + Lex.Lex(); + + // MDNode: + // !{ ... } + if (Lex.getKind() == lltok::lbrace) + return ParseMetadataListValue(ID, PFS); + + // Standalone metadata reference + // !42 + if (Lex.getKind() == lltok::APSInt) { + if (ParseMDNodeID(ID.MDNodeVal)) return true; + ID.Kind = ValID::t_MDNode; + return false; + } + + // MDString: + // ::= '!' STRINGCONSTANT + if (ParseMDString(ID.MDStringVal)) return true; + ID.Kind = ValID::t_MDString; + return false; +} + //===----------------------------------------------------------------------===// // Function Parsing. @@ -2616,16 +2622,8 @@ bool LLParser::ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V, V = Constant::getNullValue(Ty); return false; case ValID::t_Constant: - if (ID.ConstantVal->getType() != Ty) { - // Allow a constant struct with a single member to be converted - // to a union, if the union has a member which is the same type - // as the struct member. - if (const UnionType* utype = dyn_cast(Ty)) { - return ParseUnionValue(utype, ID, V); - } - + if (ID.ConstantVal->getType() != Ty) return Error(ID.Loc, "constant expression type mismatch"); - } V = ID.ConstantVal; return false; @@ -2656,22 +2654,6 @@ bool LLParser::ParseTypeAndBasicBlock(BasicBlock *&BB, LocTy &Loc, return false; } -bool LLParser::ParseUnionValue(const UnionType* utype, ValID &ID, Value *&V) { - if (const StructType* stype = dyn_cast(ID.ConstantVal->getType())) { - if (stype->getNumContainedTypes() != 1) - return Error(ID.Loc, "constant expression type mismatch"); - int index = utype->getElementTypeIndex(stype->getContainedType(0)); - if (index < 0) - return Error(ID.Loc, "initializer type is not a member of the union"); - - V = ConstantUnion::get( - utype, cast(ID.ConstantVal->getOperand(0))); - return false; - } - - return Error(ID.Loc, "constant expression type mismatch"); -} - /// FunctionHeader /// ::= OptionalLinkage OptionalVisibility OptionalCallingConv OptRetAttrs @@ -2704,6 +2686,8 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { break; case GlobalValue::PrivateLinkage: case GlobalValue::LinkerPrivateLinkage: + case GlobalValue::LinkerPrivateWeakLinkage: + case GlobalValue::LinkerPrivateWeakDefAutoLinkage: case GlobalValue::InternalLinkage: case GlobalValue::AvailableExternallyLinkage: case GlobalValue::LinkOnceAnyLinkage: @@ -2733,7 +2717,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { if (NameID != NumberedVals.size()) return TokError("function expected to be numbered '%" + - utostr(NumberedVals.size()) + "'"); + Twine(NumberedVals.size()) + "'"); } else { return TokError("expected function name"); } @@ -2840,7 +2824,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { Fn = cast(I->second.first); if (Fn->getType() != PFT) return Error(NameLoc, "type of definition and forward reference of '@" + - utostr(NumberedVals.size()) +"' disagree"); + Twine(NumberedVals.size()) + "' disagree"); ForwardRefValIDs.erase(I); } } @@ -2874,7 +2858,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { // Set the name, if it conflicted, it will be auto-renamed. ArgIt->setName(ArgList[i].Name); - if (ArgIt->getNameStr() != ArgList[i].Name) + if (ArgIt->getName() != ArgList[i].Name) return Error(ArgList[i].Loc, "redefinition of argument '%" + ArgList[i].Name + "'"); } @@ -2960,7 +2944,7 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) { // With a normal result, we check to see if the instruction is followed by // a comma and metadata. if (EatIfPresent(lltok::comma)) - if (ParseInstructionMetadata(Inst)) + if (ParseInstructionMetadata(Inst, &PFS)) return true; break; case InstExtraComma: @@ -2968,7 +2952,7 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) { // If the instruction parser ate an extra comma at the end of it, it // *must* be followed by metadata. - if (ParseInstructionMetadata(Inst)) + if (ParseInstructionMetadata(Inst, &PFS)) return true; break; } @@ -3975,6 +3959,10 @@ int LLParser::ParseInsertValue(Instruction *&Inst, PerFunctionState &PFS) { /// ::= 'null' | TypeAndValue bool LLParser::ParseMDNodeVector(SmallVectorImpl &Elts, PerFunctionState *PFS) { + // Check for an empty list. + if (Lex.getKind() == lltok::rbrace) + return false; + do { // Null is a special case since it is typeless. if (EatIfPresent(lltok::kw_null)) {