fix a crash on invalid metadata, e.g.: call i32 @foo(), XXXX
authorChris Lattner <sabre@nondot.org>
Wed, 7 Apr 2010 04:08:57 +0000 (04:08 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 7 Apr 2010 04:08:57 +0000 (04:08 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100602 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLParser.cpp
lib/AsmParser/LLParser.h

index cdad0770a38af9bebe71b204cdea728d42a62d73..7eff9cc7e36d79215b52f0f765d3662873e7ea84 100644 (file)
@@ -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));
index ae460bbb57b35d740bb881a9162b69c6596a99b1..c8f669f641a8f8aa6d77acb0fc145d1a97b33e8c 100644 (file)
@@ -74,7 +74,7 @@ namespace llvm {
   public:
     typedef LLLexer::LocTy LocTy;
   private:
-    LLVMContextContext;
+    LLVMContext &Context;
     LLLexer Lex;
     Module *M;