AST: adjust ObjC MS mangling to work with typedefs
Rather than hardcode the pointerness of the `id` and `class` types,
handle them generically. This allows for the template type
specialization of `remove_pointer<id>` which would look through the `id`
type and deal with the `objc_object` structure without the pointer.
llvm-svn: 323241
diff --git a/clang/test/CodeGenObjCXX/msabi-objc-types.mm b/clang/test/CodeGenObjCXX/msabi-objc-types.mm
index 013a9c8..42db40a 100644
--- a/clang/test/CodeGenObjCXX/msabi-objc-types.mm
+++ b/clang/test/CodeGenObjCXX/msabi-objc-types.mm
@@ -33,7 +33,7 @@
// CHECK-LABEL: "\01?g@@YAXAAPAUobjc_object@@@Z"
void g(const id &) {}
-// CHECK-LABEL: "\01?g@@YAXABPAUobjc_object@@@Z"
+// CHECK-LABEL: "\01?g@@YAXABQAUobjc_object@@@Z"
void g(id &&) {}
// CHECK-LABEL: "\01?g@@YAX$$QAPAUobjc_object@@@Z"
@@ -45,7 +45,7 @@
// CHECK-LABEL: "\01?h@@YAXAAPAUobjc_class@@@Z"
void h(const Class &) {}
-// CHECK-LABEL: "\01?h@@YAXABPAUobjc_class@@@Z"
+// CHECK-LABEL: "\01?h@@YAXABQAUobjc_class@@@Z"
void h(Class &&) {}
// CHECK-LABEL: "\01?h@@YAX$$QAPAUobjc_class@@@Z"
@@ -62,6 +62,12 @@
const I &l() { return *kI; }
// CHECK-LABEL: "\01?l@@YAABUI@@XZ"
+void m(const id) {}
+// CHECK-LABEL: "\01?m@@YAXQAUobjc_object@@@Z"
+
+void m(const I *) {}
+// CHECK-LABEL: "\01?m@@YAXPBUI@@@Z"
+
struct __declspec(dllexport) s {
struct s &operator=(const struct s &) = delete;
@@ -93,16 +99,16 @@
// CHECK-LABEL: "\01?m@s@@QAAX$$QAPAUobjc_object@@@Z"
void m(const id &) {}
- // CHECK-LABEL: "\01?m@s@@QAAXABPAUobjc_object@@@Z"
+ // CHECK-LABEL: "\01?m@s@@QAAXABQAUobjc_object@@@Z"
void m(const id &&) {}
- // CHECK-LABEL: "\01?m@s@@QAAX$$QBPAUobjc_object@@@Z"
+ // CHECK-LABEL: "\01?m@s@@QAAX$$QBQAUobjc_object@@@Z"
void m(Class *) {}
// CHECK-LABEL: "\01?m@s@@QAAXPAPAUobjc_class@@@Z"
void m(const Class *) {}
- // CHECK-LABEL: "\01?m@s@@QAAXPBPAUobjc_class@@@Z"
+ // CHECK-LABEL: "\01?m@s@@QAAXPBQAUobjc_class@@@Z"
void m(Class) {}
// CHECK-LABEL: "\01?m@s@@QAAXPAUobjc_class@@@Z"
@@ -111,12 +117,31 @@
// CHECK-LABEL: "\01?m@s@@QAAXAAPAUobjc_class@@@Z"
void m(const Class &) {}
- // CHECK-LABEL: "\01?m@s@@QAAXABPAUobjc_class@@@Z"
+ // CHECK-LABEL: "\01?m@s@@QAAXABQAUobjc_class@@@Z"
void m(Class &&) {}
// CHECK-LABEL: "\01?m@s@@QAAX$$QAPAUobjc_class@@@Z"
void m(const Class &&) {}
- // CHECK-LABEL: "\01?m@s@@QAAX$$QBPAUobjc_class@@@Z"
+ // CHECK-LABEL: "\01?m@s@@QAAX$$QBQAUobjc_class@@@Z"
};
+template <typename T>
+struct remove_pointer { typedef T type; };
+
+template <typename T>
+struct remove_pointer<T *> {
+ typedef T type;
+};
+
+template <typename T>
+struct t {
+ t() {}
+};
+
+template struct t<id>;
+// CHECK-LABEL: "\01??0?$t@PAUobjc_object@@@@QAA@XZ"
+
+template struct t<remove_pointer<id>::type>;
+// CHECK-LABEL: "\01??0?$t@Uobjc_object@@@@QAA@XZ"
+