[ms-cxxabi] Fix a number of bugs in the mangler.

This includes the following fixes:
 - Implement 4 subtly different variants of qualifier mangling and use them
   in what I believe are the right places.
 - Fix handling of array types.  Previously we were always decaying them,
   which is wrong if the type appears as a template argument, pointee,
   referent etc.
Fixes PR13182.

Differential Revision: http://llvm-reviews.chandlerc.com/D709

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180250 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGenCXX/mangle-ms-templates.cpp b/test/CodeGenCXX/mangle-ms-templates.cpp
index 7b7f30b..10e6824 100644
--- a/test/CodeGenCXX/mangle-ms-templates.cpp
+++ b/test/CodeGenCXX/mangle-ms-templates.cpp
@@ -3,7 +3,7 @@
 template<typename T>
 class Class {
  public:
-  void method() {}
+  Class() {}
 };
 
 class Typename { };
@@ -32,24 +32,30 @@
 
 void template_mangling() {
   Class<Typename> c1;
-  c1.method();
-// CHECK: call {{.*}} @"\01?method@?$Class@VTypename@@@@QAEXXZ"
+// CHECK: call {{.*}} @"\01??0?$Class@VTypename@@@@QAE@XZ"
 
   Class<const Typename> c1_const;
+// CHECK: call {{.*}} @"\01??0?$Class@$$CBVTypename@@@@QAE@XZ"
   Class<volatile Typename> c1_volatile;
+// CHECK: call {{.*}} @"\01??0?$Class@$$CCVTypename@@@@QAE@XZ"
   Class<const volatile Typename> c1_cv;
-  c1_const.method();
-  c1_volatile.method();
-  c1_cv.method();
-// Types with qualifiers have an extra $$C escape when used as template
-// arguments.  Not sure why.
-// CHECK: call {{.*}} @"\01?method@?$Class@$$CBVTypename@@@@QAEXXZ"
-// CHECK: call {{.*}} @"\01?method@?$Class@$$CCVTypename@@@@QAEXXZ"
-// CHECK: call {{.*}} @"\01?method@?$Class@$$CDVTypename@@@@QAEXXZ"
+// CHECK: call {{.*}} @"\01??0?$Class@$$CDVTypename@@@@QAE@XZ"
 
   Class<Nested<Typename> > c2;
-  c2.method();
-// CHECK: call {{.*}} @"\01?method@?$Class@V?$Nested@VTypename@@@@@@QAEXXZ"
+// CHECK: call {{.*}} @"\01??0?$Class@V?$Nested@VTypename@@@@@@QAE@XZ"
+
+  Class<int * const> c_intpc;
+// CHECK: call {{.*}} @"\01??0?$Class@QAH@@QAE@XZ"
+  Class<int()> c_ft;
+// CHECK: call {{.*}} @"\01??0?$Class@$$A6AHXZ@@QAE@XZ"
+  Class<int[]> c_inti;
+// CHECK: call {{.*}} @"\01??0?$Class@$$BY0A@H@@QAE@XZ"
+  Class<int[5]> c_int5;
+// CHECK: call {{.*}} @"\01??0?$Class@$$BY04H@@QAE@XZ"
+  Class<const int[5]> c_intc5;
+// CHECK: call {{.*}} @"\01??0?$Class@$$BY04$$CBH@@QAE@XZ"
+  Class<int * const[5]> c_intpc5;
+// CHECK: call {{.*}} @"\01??0?$Class@$$BY04QAH@@QAE@XZ"
 
   BoolTemplate<false> _false;
 // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QAE@XZ"