Finally fix PR2189.  This makes a fairly invasive but important change to
move getAsArrayType into ASTContext instead of being a method on type.
This is required because getAsArrayType(const AT), where AT is a typedef
for "int[10]" needs to return ArrayType(const int, 10).

Fixing this greatly simplifies getArrayDecayedType, which is a good sign.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54317 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 815e296..df90ee0 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -393,11 +393,10 @@
     }
 
     uint64_t NumArrayElements = AType->getNumElements();
-    QualType ElementType = E->getType()->getAsArrayType()->getElementType();
+    QualType ElementType = CGF.getContext().getCanonicalType(E->getType());
+    ElementType =CGF.getContext().getAsArrayType(ElementType)->getElementType();
     
-    unsigned CVRqualifier =
-      CGF.getContext().getCanonicalType(E->getType())->getAsArrayType()
-                            ->getElementType().getCVRQualifiers();
+    unsigned CVRqualifier = ElementType.getCVRQualifiers();
 
     for (uint64_t i = 0; i != NumArrayElements; ++i) {
       llvm::Value *NextVal = Builder.CreateStructGEP(DestPtr, i, ".array");