[llvm] r231722 - LLParser: gep: Simplify parsing error handling

David Blaikie dblaikie at gmail.com
Mon Mar 9 16:08:45 PDT 2015


Author: dblaikie
Date: Mon Mar  9 18:08:44 2015
New Revision: 231722

URL: http://llvm.org/viewvc/llvm-project?rev=231722&view=rev
Log:
LLParser: gep: Simplify parsing error handling

Modified:
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/test/Assembler/getelementptr_invalid_ptr.ll

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=231722&r1=231721&r2=231722&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Mar  9 18:08:44 2015
@@ -5465,21 +5465,15 @@ int LLParser::ParseGetElementPtr(Instruc
       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)) {

Modified: llvm/trunk/test/Assembler/getelementptr_invalid_ptr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/getelementptr_invalid_ptr.ll?rev=231722&r1=231721&r2=231722&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/getelementptr_invalid_ptr.ll (original)
+++ llvm/trunk/test/Assembler/getelementptr_invalid_ptr.ll Mon Mar  9 18:08:44 2015
@@ -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





More information about the llvm-commits mailing list