remove uses of QualType::getCanonicalType() from codegen for PR2189


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54107 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index da8350b..c44af4b 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -345,8 +345,8 @@
 /// specified destination type, both of which are LLVM scalar types.
 Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
                                                QualType DstType) {
-  SrcType = SrcType.getCanonicalType();
-  DstType = DstType.getCanonicalType();
+  SrcType = CGF.getContext().getCanonicalType(SrcType);
+  DstType = CGF.getContext().getCanonicalType(DstType);
   if (SrcType == DstType) return Src;
   
   if (DstType->isVoidType()) return 0;
@@ -421,7 +421,7 @@
 EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src,
                               QualType SrcTy, QualType DstTy) {
   // Get the source element type.
-  SrcTy = cast<ComplexType>(SrcTy.getCanonicalType())->getElementType();
+  SrcTy = SrcTy->getAsComplexType()->getElementType();
   
   // Handle conversions to bool first, they are special: comparisons against 0.
   if (DstTy->isBooleanType()) {
@@ -546,10 +546,6 @@
     return V;
     
   } else if (E->getType()->isReferenceType()) {
-    assert(cast<ReferenceType>(E->getType().getCanonicalType())->
-           getPointeeType() == 
-           Op->getType().getCanonicalType() && "Incompatible types!");
-    
     return EmitLValue(Op).getAddress();
   }
   
@@ -819,7 +815,7 @@
     // Zero or sign extend the pointer value based on whether the index is
     // signed or not.
     const llvm::Type *IdxType = llvm::IntegerType::get(CGF.LLVMPointerWidth);
-    if (IdxExp->getType().getCanonicalType()->isSignedIntegerType())
+    if (IdxExp->getType()->isSignedIntegerType())
       Idx = Builder.CreateSExt(Idx, IdxType, "idx.ext");
     else
       Idx = Builder.CreateZExt(Idx, IdxType, "idx.ext");
@@ -843,7 +839,7 @@
     // Zero or sign extend the pointer value based on whether the index is
     // signed or not.
     const llvm::Type *IdxType = llvm::IntegerType::get(CGF.LLVMPointerWidth);
-    if (Ops.E->getRHS()->getType().getCanonicalType()->isSignedIntegerType())
+    if (Ops.E->getRHS()->getType()->isSignedIntegerType())
       Idx = Builder.CreateSExt(Idx, IdxType, "idx.ext");
     else
       Idx = Builder.CreateZExt(Idx, IdxType, "idx.ext");
@@ -862,8 +858,8 @@
   Value *LHS = Visit(E->getLHS());
   Value *RHS = Visit(E->getRHS());
   
-  const QualType LHSType = E->getLHS()->getType().getCanonicalType();
-  const QualType LHSElementType = cast<PointerType>(LHSType)->getPointeeType();
+  const QualType LHSType = E->getLHS()->getType();
+  const QualType LHSElementType = LHSType->getAsPointerType()->getPointeeType();
   uint64_t ElementSize = CGF.getContext().getTypeSize(LHSElementType) / 8;
   
   const llvm::Type *ResultType = ConvertType(E->getType());
@@ -948,8 +944,7 @@
     CodeGenFunction::ComplexPairTy LHS = CGF.EmitComplexExpr(E->getLHS());
     CodeGenFunction::ComplexPairTy RHS = CGF.EmitComplexExpr(E->getRHS());
     
-    QualType CETy = 
-      cast<ComplexType>(LHSTy.getCanonicalType())->getElementType();
+    QualType CETy = LHSTy->getAsComplexType()->getElementType();
     
     Value *ResultR, *ResultI;
     if (CETy->isRealFloatingType()) {