Sfoglia il codice sorgente

AsmParser: Don't crash on malformed attribute groups

This fixes PR21785.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223801 91177308-0d34-0410-b5e6-96231b3b80d8
David Majnemer 10 anni fa
parent
commit
db7b69e3a6
2 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 3 1
      lib/AsmParser/LLParser.cpp
  2. 4 0
      test/Assembler/invalid-attrgrp.ll

+ 3 - 1
lib/AsmParser/LLParser.cpp

@@ -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;

+ 4 - 0
test/Assembler/invalid-attrgrp.ll

@@ -0,0 +1,4 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+attributes
+; CHECK: expected attribute group id