[llvm] r224053 - AsmParser: Don't crash on an ill-formed MDNodeVector

David Majnemer david.majnemer at gmail.com
Thu Dec 11 12:44:10 PST 2014


Author: majnemer
Date: Thu Dec 11 14:44:09 2014
New Revision: 224053

URL: http://llvm.org/viewvc/llvm-project?rev=224053&view=rev
Log:
AsmParser: Don't crash on an ill-formed MDNodeVector

Added:
    llvm/trunk/test/Assembler/invalid-mdnode-vector.ll
Modified:
    llvm/trunk/lib/AsmParser/LLParser.cpp

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=224053&r1=224052&r2=224053&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Thu Dec 11 14:44:09 2014
@@ -4686,8 +4686,8 @@ int LLParser::ParseInsertValue(Instructi
 ///   ::= 'null' | TypeAndValue
 bool LLParser::ParseMDNodeVector(SmallVectorImpl<Metadata *> &Elts,
                                  PerFunctionState *PFS) {
-  assert(Lex.getKind() == lltok::lbrace);
-  Lex.Lex();
+  if (ParseToken(lltok::lbrace, "expected '{' here"))
+    return true;
 
   // Check for an empty list.
   if (EatIfPresent(lltok::rbrace))

Added: llvm/trunk/test/Assembler/invalid-mdnode-vector.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-mdnode-vector.ll?rev=224053&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-mdnode-vector.ll (added)
+++ llvm/trunk/test/Assembler/invalid-mdnode-vector.ll Thu Dec 11 14:44:09 2014
@@ -0,0 +1,4 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+!0 = metadata!
+; CHECK: expected '{' here





More information about the llvm-commits mailing list