diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-07 04:08:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-07 04:08:57 +0000 |
commit | 2e664bd9155f963bc9410ce4bb5d0b1a72edd5a0 (patch) | |
tree | a8a16f3edb57901f7acf7b4d6397571c6d9f4de6 /llvm/lib/AsmParser/LLParser.cpp | |
parent | dd1c82141c18daaa65f1ed93f5a7cd49ce97ba63 (diff) | |
download | bcm5719-llvm-2e664bd9155f963bc9410ce4bb5d0b1a72edd5a0.tar.gz bcm5719-llvm-2e664bd9155f963bc9410ce4bb5d0b1a72edd5a0.zip |
fix a crash on invalid metadata, e.g.: call i32 @foo(), XXXX
We would return the error without inserting the new instruction
into the program, so it wouldn't get deallocated, and an abort
would trigger when the module was deleted.
llvm-svn: 100602
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index cdad0770a38..7eff9cc7e36 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -2933,6 +2933,8 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) { default: assert(0 && "Unknown ParseInstruction result!"); case InstError: return true; case InstNormal: + BB->getInstList().push_back(Inst); + // With a normal result, we check to see if the instruction is followed by // a comma and metadata. if (EatIfPresent(lltok::comma)) @@ -2940,6 +2942,8 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) { return true; break; case InstExtraComma: + BB->getInstList().push_back(Inst); + // If the instruction parser ate an extra comma at the end of it, it // *must* be followed by metadata. if (ParseInstructionMetadata(Inst)) @@ -2947,8 +2951,6 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) { break; } - BB->getInstList().push_back(Inst); - // Set the name on the instruction. if (PFS.SetInstName(NameID, NameStr, NameLoc, Inst)) return true; } while (!isa<TerminatorInst>(Inst)); |