LLParser: gep: Simplify parsing error handling

llvm-svn: 231722
This commit is contained in:
David Blaikie 2015-03-09 23:08:44 +00:00
parent c37ed67e4a
commit d9778583bf
2 changed files with 5 additions and 11 deletions

View File

@ -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<VectorType>(PtrTy))
PtrTy = VT->getElementType();
SequentialType *SeqPtrTy = dyn_cast<SequentialType>(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<PointerType>(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<Value*, 16> Indices;
bool AteExtraComma = false;
while (EatIfPresent(lltok::comma)) {

View File

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