From 5b71fffa58913a265edc909d5b912512c00f9e7a Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 11 Feb 2015 09:13:11 +0000 Subject: [PATCH] AsmParser: Validate alloca's type An alloca's type should be weird things like metadata. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228820 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AsmParser/LLParser.cpp | 3 +++ test/Assembler/alloca-invalid-type.ll | 9 +++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/Assembler/alloca-invalid-type.ll diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index adf4c9073ab..7af85b5846c 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -4633,6 +4633,9 @@ int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) { if (ParseType(Ty)) return true; + if (!PointerType::isValidElementType(Ty)) + return TokError("pointer to this type is invalid"); + bool AteExtraComma = false; if (EatIfPresent(lltok::comma)) { if (Lex.getKind() == lltok::kw_align) { diff --git a/test/Assembler/alloca-invalid-type.ll b/test/Assembler/alloca-invalid-type.ll new file mode 100644 index 00000000000..fb2c05cc35a --- /dev/null +++ b/test/Assembler/alloca-invalid-type.ll @@ -0,0 +1,9 @@ +; RUN: not llvm-as < %s 2>&1 | FileCheck %s + +; CHECK: pointer to this type is invalid + +define void @test() { +entry: + alloca metadata !{null} + ret void +}