[llvm] r223801 - AsmParser: Don't crash on malformed attribute groups
David Majnemer
david.majnemer at gmail.com
Tue Dec 9 10:33:57 PST 2014
Author: majnemer
Date: Tue Dec 9 12:33:57 2014
New Revision: 223801
URL: http://llvm.org/viewvc/llvm-project?rev=223801&view=rev
Log:
AsmParser: Don't crash on malformed attribute groups
This fixes PR21785.
Added:
llvm/trunk/test/Assembler/invalid-attrgrp.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=223801&r1=223800&r2=223801&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Dec 9 12:33:57 2014
@@ -869,7 +869,9 @@ bool LLParser::ParseUnnamedAttrGrp() {
LocTy AttrGrpLoc = Lex.getLoc();
Lex.Lex();
- assert(Lex.getKind() == lltok::AttrGrpID);
+ if (Lex.getKind() != lltok::AttrGrpID)
+ return TokError("expected attribute group id");
+
unsigned VarID = Lex.getUIntVal();
std::vector<unsigned> unused;
LocTy BuiltinLoc;
Added: llvm/trunk/test/Assembler/invalid-attrgrp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-attrgrp.ll?rev=223801&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-attrgrp.ll (added)
+++ llvm/trunk/test/Assembler/invalid-attrgrp.ll Tue Dec 9 12:33:57 2014
@@ -0,0 +1,4 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+attributes
+; CHECK: expected attribute group id
More information about the llvm-commits
mailing list