[llvm] r228820 - AsmParser: Validate alloca's type
David Majnemer
david.majnemer at gmail.com
Wed Feb 11 01:13:11 PST 2015
Author: majnemer
Date: Wed Feb 11 03:13:11 2015
New Revision: 228820
URL: http://llvm.org/viewvc/llvm-project?rev=228820&view=rev
Log:
AsmParser: Validate alloca's type
An alloca's type should be weird things like metadata.
Added:
llvm/trunk/test/Assembler/alloca-invalid-type.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=228820&r1=228819&r2=228820&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Feb 11 03:13:11 2015
@@ -4633,6 +4633,9 @@ int LLParser::ParseAlloc(Instruction *&I
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) {
Added: llvm/trunk/test/Assembler/alloca-invalid-type.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/alloca-invalid-type.ll?rev=228820&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/alloca-invalid-type.ll (added)
+++ llvm/trunk/test/Assembler/alloca-invalid-type.ll Wed Feb 11 03:13:11 2015
@@ -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
+}
More information about the llvm-commits
mailing list