r323241 - AST: adjust ObjC MS mangling to work with typedefs
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 23 11:17:25 PST 2018
Author: compnerd
Date: Tue Jan 23 11:17:25 2018
New Revision: 323241
URL: http://llvm.org/viewvc/llvm-project?rev=323241&view=rev
Log:
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.
Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenObjCXX/msabi-objc-types.mm
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=323241&r1=323240&r2=323241&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Jan 23 11:17:25 2018
@@ -1833,11 +1833,9 @@ void MicrosoftCXXNameMangler::mangleType
llvm_unreachable("placeholder types shouldn't get to name mangling");
case BuiltinType::ObjCId:
- Out << "PA";
mangleArtificalTagType(TTK_Struct, "objc_object");
break;
case BuiltinType::ObjCClass:
- Out << "PA";
mangleArtificalTagType(TTK_Struct, "objc_class");
break;
case BuiltinType::ObjCSel:
@@ -2337,9 +2335,6 @@ void MicrosoftCXXNameMangler::mangleType
void MicrosoftCXXNameMangler::mangleType(const ObjCObjectPointerType *T,
Qualifiers Quals, SourceRange Range) {
- if (T->isObjCIdType() || T->isObjCClassType())
- return mangleType(T->getPointeeType(), Range, QMM_Drop);
-
QualType PointeeType = T->getPointeeType();
manglePointerCVQualifiers(Quals);
manglePointerExtQualifiers(Quals, PointeeType);
Modified: cfe/trunk/test/CodeGenObjCXX/msabi-objc-types.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/msabi-objc-types.mm?rev=323241&r1=323240&r2=323241&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/msabi-objc-types.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/msabi-objc-types.mm Tue Jan 23 11:17:25 2018
@@ -33,7 +33,7 @@ void g(id &) {}
// 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 @@ void h(Class &) {}
// 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 @@ I &k() { return *kI; }
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 @@ struct __declspec(dllexport) s {
// CHECK-LABEL: "\01?m at s@@QAAX$$QAPAUobjc_object@@@Z"
void m(const id &) {}
- // CHECK-LABEL: "\01?m at s@@QAAXABPAUobjc_object@@@Z"
+ // CHECK-LABEL: "\01?m at s@@QAAXABQAUobjc_object@@@Z"
void m(const id &&) {}
- // CHECK-LABEL: "\01?m at s@@QAAX$$QBPAUobjc_object@@@Z"
+ // CHECK-LABEL: "\01?m at s@@QAAX$$QBQAUobjc_object@@@Z"
void m(Class *) {}
// CHECK-LABEL: "\01?m at s@@QAAXPAPAUobjc_class@@@Z"
void m(const Class *) {}
- // CHECK-LABEL: "\01?m at s@@QAAXPBPAUobjc_class@@@Z"
+ // CHECK-LABEL: "\01?m at s@@QAAXPBQAUobjc_class@@@Z"
void m(Class) {}
// CHECK-LABEL: "\01?m at s@@QAAXPAUobjc_class@@@Z"
@@ -111,12 +117,31 @@ struct __declspec(dllexport) s {
// CHECK-LABEL: "\01?m at s@@QAAXAAPAUobjc_class@@@Z"
void m(const Class &) {}
- // CHECK-LABEL: "\01?m at s@@QAAXABPAUobjc_class@@@Z"
+ // CHECK-LABEL: "\01?m at s@@QAAXABQAUobjc_class@@@Z"
void m(Class &&) {}
// CHECK-LABEL: "\01?m at s@@QAAX$$QAPAUobjc_class@@@Z"
void m(const Class &&) {}
- // CHECK-LABEL: "\01?m at s@@QAAX$$QBPAUobjc_class@@@Z"
+ // CHECK-LABEL: "\01?m at 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 at PAUobjc_object@@@@QAA at XZ"
+
+template struct t<remove_pointer<id>::type>;
+// CHECK-LABEL: "\01??0?$t at Uobjc_object@@@@QAA at XZ"
+
More information about the cfe-commits
mailing list