change more instances of QualType::getCanonicalType to call
ASTContext::getCanonicalType instead (PR2189)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54105 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 9420f95..448f7ec 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -404,18 +404,20 @@
   if (E->getOpcode() == UnaryOperator::Extension)
     return EmitLValue(E->getSubExpr());
   
+  QualType ExprTy=CGM.getContext().getCanonicalType(E->getSubExpr()->getType());
   switch (E->getOpcode()) {
   default: assert(0 && "Unknown unary operator lvalue!");
   case UnaryOperator::Deref:
     return LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()),
-      E->getSubExpr()->getType().getCanonicalType()->getAsPointerType()
-      ->getPointeeType().getCVRQualifiers());
+                            ExprTy->getAsPointerType()->getPointeeType()
+                                    .getCVRQualifiers());
   case UnaryOperator::Real:
   case UnaryOperator::Imag:
     LValue LV = EmitLValue(E->getSubExpr());
     unsigned Idx = E->getOpcode() == UnaryOperator::Imag;
     return LValue::MakeAddr(Builder.CreateStructGEP(LV.getAddress(),
-      Idx, "idx"),E->getSubExpr()->getType().getCVRQualifiers());
+                                                    Idx, "idx"),
+                            ExprTy.getCVRQualifiers());
   }
 }
 
@@ -501,9 +503,11 @@
   // size is a VLA.
   if (!E->getType()->isConstantSizeType())
     assert(0 && "VLA idx not implemented");
+  QualType ExprTy = CGM.getContext().getCanonicalType(E->getBase()->getType());
+
   return LValue::MakeAddr(Builder.CreateGEP(Base, Idx, "arrayidx"),
-    E->getBase()->getType().getCanonicalType()->getAsPointerType()
-    ->getPointeeType().getCVRQualifiers());
+                          ExprTy->getAsPointerType()->getPointeeType()
+                               .getCVRQualifiers());
 }
 
 static