Finish up saving original parameter type and
using it in ObjC's method parameter encoding.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61293 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index d03ed41..791e386 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1638,11 +1638,17 @@
   // Argument types.
   ParmOffset = 2 * PtrSize;
   for (int i = 0; i < NumOfParams; i++) {
-    QualType PType = Decl->getParamDecl(i)->getType();
+    ParmVarDecl *PVDecl = Decl->getParamDecl(i);
+    QualType PType = PVDecl->getOriginalType(); 
+    if (const ArrayType *AT =
+          dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) 
+        // Use array's original type only if it has known number of
+        // elements.
+        if (!dyn_cast<ConstantArrayType>(AT))
+          PType = PVDecl->getType();
     // Process argument qualifiers for user supplied arguments; such as,
     // 'in', 'inout', etc.
-    getObjCEncodingForTypeQualifier(
-      Decl->getParamDecl(i)->getObjCDeclQualifier(), S);
+    getObjCEncodingForTypeQualifier(PVDecl->getObjCDeclQualifier(), S);
     getObjCEncodingForType(PType, S);
     S += llvm::utostr(ParmOffset);
     ParmOffset += getObjCEncodingTypeSize(PType);