From: David Blaikie Date: Mon, 9 Mar 2015 23:08:44 +0000 (+0000) Subject: LLParser: gep: Simplify parsing error handling X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=22feef493a694e618634b535cc289a12da54ac92;p=oota-llvm.git LLParser: gep: Simplify parsing error handling git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231722 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 67d74c0c121..65e622af66c 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -5465,21 +5465,15 @@ int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) { ParseTypeAndValue(Ptr, Loc, PFS)) return true; - Type *PtrTy = Ptr->getType(); - if (VectorType *VT = dyn_cast(PtrTy)) - PtrTy = VT->getElementType(); - SequentialType *SeqPtrTy = dyn_cast(PtrTy); - if (!SeqPtrTy) - return Error(Loc, "pointer type is not valid"); - if (Ty != SeqPtrTy->getElementType()) - return Error(ExplicitTypeLoc, - "explicit pointee type doesn't match operand's pointee type"); - Type *BaseType = Ptr->getType(); PointerType *BasePointerType = dyn_cast(BaseType->getScalarType()); if (!BasePointerType) return Error(Loc, "base of getelementptr must be a pointer"); + if (Ty != BasePointerType->getElementType()) + return Error(ExplicitTypeLoc, + "explicit pointee type doesn't match operand's pointee type"); + SmallVector Indices; bool AteExtraComma = false; while (EatIfPresent(lltok::comma)) { diff --git a/test/Assembler/getelementptr_invalid_ptr.ll b/test/Assembler/getelementptr_invalid_ptr.ll index ff12debc1bc..892292729a1 100644 --- a/test/Assembler/getelementptr_invalid_ptr.ll +++ b/test/Assembler/getelementptr_invalid_ptr.ll @@ -1,7 +1,7 @@ ; RUN: not llvm-as < %s 2>&1 | FileCheck %s ; Test the case of an invalid pointer type on a GEP -; CHECK: pointer type is not valid +; CHECK: base of getelementptr must be a pointer define i32* @foo(i32 %a) { %gep = getelementptr i32, i32 %a, i32 1