enhance ExtVectorElementExpr to allow V->xxyy  to work like (*V).xxyy


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64667 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 3e44c00..03efbc9 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -257,13 +257,8 @@
   if (LV.isPropertyRef())
     return EmitLoadOfPropertyRefLValue(LV, ExprType);
 
-  if (LV.isKVCRef())
-    return EmitLoadOfKVCRefLValue(LV, ExprType);
-
-  assert(0 && "Unknown LValue type!");
-  //an invalid RValue, but the assert will
-  //ensure that this point is never reached
-  return RValue();
+  assert(LV.isKVCRef() && "Unknown LValue type!");
+  return EmitLoadOfKVCRefLValue(LV, ExprType);
 }
 
 RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV,
@@ -799,7 +794,16 @@
 LValue CodeGenFunction::
 EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
   // Emit the base vector as an l-value.
-  LValue Base = EmitLValue(E->getBase());
+  LValue Base;
+
+  // ExtVectorElementExpr's base can either be a vector or pointer to vector.
+  if (const PointerType *PT = E->getBase()->getType()->getAsPointerType()) {
+    llvm::Value *Ptr = EmitScalarExpr(E->getBase());
+    Base = LValue::MakeAddr(Ptr, PT->getPointeeType().getCVRQualifiers());
+  } else {
+    assert(E->getBase()->getType()->isVectorType());
+    Base = EmitLValue(E->getBase());
+  }
 
   // Encode the element access list into a vector of unsigned indices.
   llvm::SmallVector<unsigned, 4> Indices;