eliminate a temporary smallvector

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100082 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-04-01 04:51:13 +00:00
parent 68c5513499
commit fe805249f7
2 changed files with 5 additions and 13 deletions

View File

@ -1078,9 +1078,7 @@ bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) {
/// ParseInstructionMetadata /// ParseInstructionMetadata
/// ::= !dbg !42 (',' !dbg !57)* /// ::= !dbg !42 (',' !dbg !57)*
bool LLParser:: bool LLParser::ParseInstructionMetadata(Instruction *Inst) {
ParseInstructionMetadata(SmallVectorImpl<std::pair<unsigned,
MDNode *> > &Result){
do { do {
if (Lex.getKind() != lltok::MetadataVar) if (Lex.getKind() != lltok::MetadataVar)
return TokError("expected metadata after comma"); return TokError("expected metadata after comma");
@ -1094,7 +1092,7 @@ ParseInstructionMetadata(SmallVectorImpl<std::pair<unsigned,
return true; return true;
unsigned MDK = M->getMDKindID(Name.c_str()); unsigned MDK = M->getMDKindID(Name.c_str());
Result.push_back(std::make_pair(MDK, Node)); Inst->setMetadata(MDK, Node);
// If this is the end of the list, we're done. // If this is the end of the list, we're done.
} while (EatIfPresent(lltok::comma)); } while (EatIfPresent(lltok::comma));
@ -2896,22 +2894,17 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) {
// With a normal result, we check to see if the instruction is followed by // With a normal result, we check to see if the instruction is followed by
// a comma and metadata. // a comma and metadata.
if (EatIfPresent(lltok::comma)) if (EatIfPresent(lltok::comma))
if (ParseInstructionMetadata(MetadataOnInst)) if (ParseInstructionMetadata(Inst))
return true; return true;
break; break;
case InstExtraComma: case InstExtraComma:
// If the instruction parser ate an extra comma at the end of it, it // If the instruction parser ate an extra comma at the end of it, it
// *must* be followed by metadata. // *must* be followed by metadata.
if (ParseInstructionMetadata(MetadataOnInst)) if (ParseInstructionMetadata(Inst))
return true; return true;
break; break;
} }
// Set metadata attached with this instruction.
for (unsigned i = 0, e = MetadataOnInst.size(); i != e; ++i)
Inst->setMetadata(MetadataOnInst[i].first, MetadataOnInst[i].second);
MetadataOnInst.clear();
BB->getInstList().push_back(Inst); BB->getInstList().push_back(Inst);
// Set the name on the instruction. // Set the name on the instruction.

View File

@ -171,8 +171,7 @@ namespace llvm {
bool ParseOptionalCallingConv(CallingConv::ID &CC); bool ParseOptionalCallingConv(CallingConv::ID &CC);
bool ParseOptionalAlignment(unsigned &Alignment); bool ParseOptionalAlignment(unsigned &Alignment);
bool ParseOptionalStackAlignment(unsigned &Alignment); bool ParseOptionalStackAlignment(unsigned &Alignment);
bool ParseInstructionMetadata(SmallVectorImpl<std::pair<unsigned, bool ParseInstructionMetadata(Instruction *Inst);
MDNode *> > &);
bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma); bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma);
bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,bool &AteExtraComma); bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,bool &AteExtraComma);
bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) { bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {