From 72981cdce365dadc945929e6a9b2dc45811f4e58 Mon Sep 17 00:00:00 2001
From: David Blaikie <dblaikie@gmail.com>
Date: Fri, 17 Apr 2015 22:32:13 +0000
Subject: [PATCH] [opaque pointer type] Use the parsed explicit pointee type
 when error-checking geps during LL parsing

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235233 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/AsmParser/LLParser.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 546363b9cb1..be098c1b128 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -5542,13 +5542,10 @@ int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) {
   }
 
   SmallPtrSet<const Type*, 4> Visited;
-  if (!Indices.empty() &&
-      !BasePointerType->getElementType()->isSized(&Visited))
+  if (!Indices.empty() && !Ty->isSized(&Visited))
     return Error(Loc, "base element of getelementptr must be sized");
 
-  if (!GetElementPtrInst::getIndexedType(
-          cast<PointerType>(BaseType->getScalarType())->getElementType(),
-          Indices))
+  if (!GetElementPtrInst::getIndexedType(Ty, Indices))
     return Error(Loc, "invalid getelementptr indices");
   Inst = GetElementPtrInst::Create(Ty, Ptr, Indices);
   if (InBounds)
-- 
2.34.1